Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 111441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:23:09+00:00 2026-05-11T02:23:09+00:00

I have this method Verify_X which is called during databind for a listbox selected

  • 0

I have this method Verify_X which is called during databind for a listbox selected value. The problem is the strongly typed datasource. I want to use the abstract class BaseDataSource or an interface to call the methods supported: Parameters[] and Select(), Instead of using the most specific implementation as seen below.

This is so one method can be used for all the different types of datasources I have instead of having a method for each. They all inherit the same way.

Here is the chain of inheritance / implementation

public class DseDataSource : ProviderDataSource<SCCS.BLL.Dse, DseKey>  public abstract class ProviderDataSource<Entity, EntityKey> : BaseDataSource<Entity, EntityKey>, ILinkedDataSource, IListDataSource     where Entity : SCCS.BLL.IEntityId<EntityKey>, new()     where EntityKey : SCCS.BLL.IEntityKey, new()  public abstract class BaseDataSource<Entity, EntityKey> : DataSourceControl, IListDataSource, IDataSourceEvents     where Entity : new()     where EntityKey : new() 

The BaseDataSource has the methods and properties I need. DseDataSource is implemented the following way:

public class DseDataSource : ProviderDataSource<SCCS.BLL.Dse, DseKey> 

I know it is possible to edit the class DseDataSource, add an interface to access Parameters[] and Select(), then program against that, which allows what I want, but this requires editing the NetTiers libraries and I am curious to see if this can be done since it seemed so difficult.

    public static string Verify_DSE(string valueToBind, DseDataSource dataSource)     {         if (ListContainsValue(dataSource.GetEntityList(), valueToBind)) return valueToBind;         CustomParameter p = dataSource.Parameters['WhereClause'] as CustomParameter;         if (p != null)         {             p.Value = 'IsActive=true OR Id=' + valueToBind;             dataSource.Select();             return valueToBind;         }         return string.Empty;     }      private static bool ListContainsValue(IEnumerable list, string value)     {         if (value.Length == 0) return true;          foreach (object o in list)         {             IEntity entity = o as IEntity;             if (entity != null)             {                 if (entity.Id.ToString() == value)                     return true;             }         }         return false;     } 

The end result would be code such as:

public static string Verify(string valueToBind, object dataSource) { //what is the correct way to convert from object BaseDataSource baseInstance = dataSource as BaseDataSource;  if baseInstance != null) {     if (ListContainsValue(baseInstance.GetEntityList(), valueToBind)) return valueToBind;     CustomParameter p = baseInstance.Parameters['WhereClause'] as CustomParameter;     if (p != null)     {         p.Value = 'IsActive=true OR Id=' + valueToBind;         baseInstance.Select();         return valueToBind;     } }  return string.Empty; } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T02:23:10+00:00Added an answer on May 11, 2026 at 2:23 am

    If you are unable to alter the class definition or to use some sort of extension methods, you can use Reflection. Here is a sample that I worked up using assumptions about your code:

        public static string Verify(string valueToBind, object dataSource)     {         ////what is the correct way to convert from object         //BaseDataSource baseInstance = dataSource as BaseDataSource;         Type type = dataSource.GetType();         MethodInfo select = type.GetMethod('Select');         PropertyInfo parameters = type.GetProperty('Parameters');         PropertyInfo parameterGetter = null;         object parametersInstance = null;         if (parameters != null)         {             parametersInstance = parameters.GetValue(dataSource, null);             type = parametersInstance.GetType();             parameterGetter = type.GetProperty('Item');         }          //if baseInstance != null)         if (select != null && parameters != null && parameterGetter != null)         {                 if (ListContainsValue(baseInstance.GetEntityList(), valueToBind)) return valueToBind;                 CustomParameter p = parameterGetter.GetValue(parametersInstance, new object[] {'WhereClause' }) as CustomParameter;                  if (p != null)                 {                         p.Value = 'IsActive=true OR Id=' + valueToBind;                         select.Invoke(dataSource, null);                         return valueToBind;                 }         }          return string.Empty;     } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 64k
  • Answers 64k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer After all Eclipse's plugin TCP/IP Monitor was apparently not giving… May 11, 2026 at 10:46 am
  • added an answer Why not just label/tag the trunk with 'OldVersion' and continue… May 11, 2026 at 10:46 am
  • added an answer This is most probably because you annotated the id field… May 11, 2026 at 10:46 am

Related Questions

I have this method Verify_X which is called during databind for a listbox selected
I have this method on a webpart: private IFilterData _filterData = null; [ConnectionConsumer(Filter Data
I have this method in my db class public function query($queryString) { if (!$this->_connected)
I have this method: public bool CanExecute() And after 70 commits, I added an
I have this method: private delegate void watcherReader(StreamReader sr); private void watchProc(StreamReader sr) {
Currently i have this method: static boolean checkDecimalPlaces(double d, int decimalPlaces){ if (d==0) return
I have this function from a plugin (from a previous post) // This method
So i have this method: internal K GetValue<T, K>(T source, string col) where T
I have this factory method in java: public static Properties getConfigFactory() throws ClassNotFoundException, IOException
Suppose I have this interface public interface IFoo { ///<summary> /// Foo method ///</summary>

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.