DisplayMember not set

Thread is closed for posting
2 posts, 0 answers
  1. DNV Cleaner Energy
    DNV Cleaner Energy avatar
    6 posts
    Member since:
    Apr 2009

    Posted 09 Feb 2010 Link to this post

    I have a Winforms RadCombo box for which I am attempting to set a class derived from CollectionBase as the DataSource. I find that the DisplayMember of the comboxbox is set to an empty string. The ValueMember retains the correct column setting.

    Any help is really appreciated...

    Here are the relevant pieces of code:

     public class FixedBillingPackageList : ReadOnlyCollectionBase

            #region Data Structure
            public struct FixedBillingPackageListInfo
                // This has private members, public properties because
                // ASP.NET can't data bind to public members of a structure
                private int _fixedBillingPackageID; //**PK
                private string _packageName;
                private decimal _rate;

                public int FixedBillingPackageID
                    get { return _fixedBillingPackageID; }
                    set { _fixedBillingPackageID = value; }

                public string PackageName
                    get { return _packageName; }
                    set { _packageName = value; }
                public decimal Rate
                    get { return _rate; }
                    set { _rate = value; }

                public string PackageNamePrice
                        return String.Format("{0} ({1})", _packageName, _rate);
            #endregion //Data Structure

           #region Data Access
            protected void Fetch(object criteria)
                //retrieve data from database
                Criteria crit = (Criteria)criteria;
                Database database = DatabaseFactory.CreateDatabase("ConnectionString");
                DbCommand dbCommand = database.GetSqlStringCommand("SELECT FixedBillingPackage.FixedBillingPackageID AS FixedBillingPackageID, FixedBillingPackage.PackageName AS PackageName, FixedBillingPackage.Rate AS Rate FROM FixedBillingPackage ");
                dbCommand.CommandType = CommandType.Text;
                SafeDataReader dataReader = new SafeDataReader(database.ExecuteReader(dbCommand));
                    // Insert Blank row at the top of the list if specified.
                    if (crit.IncludeBlankRow)
                        FixedBillingPackageListInfo info = new FixedBillingPackageListInfo();
                        info.FixedBillingPackageID = -1;
                        info.PackageName = String.Empty;
                        info.Rate = 0;

                    while (dataReader.Read())
                        FixedBillingPackageListInfo info = new FixedBillingPackageListInfo();
                        info.FixedBillingPackageID = dataReader.GetInt16(0);
                        info.PackageName = dataReader.GetString(1);
                        info.Rate = dataReader.GetDecimal(2);

            #endregion Data Access


    public MainForm()

    private void InitializeData()

                FixedBillingPackageList packageList = FixedBillingPackageList.GetFixedBillingPackageList(true);
                comboFixedBillingPackage.BindingContext = new BindingContext();
                this.comboFixedBillingPackage.DisplayMember = "PackageName";
                this.comboFixedBillingPackage.ValueMember = "FixedBillingPackageID";
                comboFixedBillingPackage.DataSource = packageList;
  2. Victor
    Victor avatar
    1358 posts

    Posted 11 Feb 2010 Link to this post

    Hello Veeramani Pulacode,

    Thank you for writing. I am afraid that the code you provided will not work because the standard complex data binding mechanism supports only IList and IListSource interfaces. Your collection needs to implement one of those. If you try the same code with the standard Microsoft ComboBox control it will throw an exception. Basically you need IList in order to work with any list control be it a combobox, listbox, grid etc.

    Please write again if you need further assistance.

    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
Back to Top