DataBinding issue with ComboBox

5 posts, 0 answers
  1. Stargazer
    Stargazer avatar
    73 posts
    Member since:
    Jan 2007

    Posted 12 May 2010 Link to this post

    And probably with RadListBox also.

    The problem is as follows: I have a RadComboBox, with DataSource, DisplayMember and ValueMember defined. It get's populated just fine:
    cmbNewTipoUtente.ValueMember = "ID_TipoUtente";  
    cmbNewTipoUtente.DisplayMember = "Designacao";  
    cmbNewTipoUtente.DataSource = dt; //<- DataTable 

    The same RadComboBox has a DataBinding on SelectedValue to a property on a POCO object. Something like this:
    cmbNewTipoUtente.DataBindings.Add("SelectedValue", mNewTipoUtente, "ID_TipoUtente"true, DataSourceUpdateMode.OnPropertyChanged, null); 

    Also have the SelectedIndexChanged event subscribed where I check for some conditions. In the event, I'm checking the value on the ID_TipoUtente property so I can pass it to a method on my business layer. This is where the problem lays (and I think it is a bug), whenever I selecte an item on the RadComboBox, the value of my property do not get updated.

    I tryed to open a Bug Report, but it seems there's also a bug on My Account section of the site, since there is only one product available to me, where should be almost all of them. lol

    This is a big issue since many of my features are broken because of this and can cause me some pain with my clients.
  2. Stargazer
    Stargazer avatar
    73 posts
    Member since:
    Jan 2007

    Posted 13 May 2010 Link to this post

    Hello, I managed to get my account to work again and managed to open a ticket. Meanwhile me and a colleague, were able to come up with a workaround for this issue, which I'll put here for those of you experiencing same issues.

    We created a new class, inheriting from RadComboBox, and override OnSelectedIndexChanged. In there, basically we access the binding object and force the change to it. So, as an image is better than a thousand words, here we have:

    protected override void OnSelectedIndexChanged(EventArgs e) 
        //Pesquisa e verifica se a propriedade SelectedValue está bound,  
        //caso esteja actualiza o valor do objecto 
        if (base.DataBindings != null && base.DataBindings.Count > 0) 
            foreach (Binding binding in base.DataBindings) 
                if (binding.PropertyName.Equals("SelectedValue")) 
                    object objBound = binding.DataSource; 
                    string nomePropriedade = binding.BindingMemberInfo.BindingField; 
                    PropertyInfo propriedade = objBound.GetType().GetProperty(nomePropriedade); 
                    if (propriedade.GetValue(objBound, null) != this.SelectedValue) 
        //Chama o método base 

    Same results are achieved if one adopts the same approach to RadListBox. Hope it helps!
  3. DevCraft R3 2016 release webinar banner
  4. Victor
    Victor avatar
    1349 posts

    Posted 18 May 2010 Link to this post

    Hi Stargazer,

    Thank you for sharing this information. We will look into the issue and will address it if it is on our side.

    Sincerely yours,
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Peter
    Peter avatar
    9 posts
    Member since:
    Aug 2016

    Posted 07 Aug in reply to Victor Link to this post

    Hi Victor,

    I was trying to databind the RadTextBox so that when user choose one item in the RadListView,the related data can be shown in the textbox. But  I found that there was no DataSource property for RadTextBox and I searched on the Internet,someone suggested RadComboBox(hide the dropdown arrow).The problem is I could not find the RadComboBox in the toolbox,could you give me some guide?



  6. Dess
    Dess avatar
    1561 posts

    Posted 15 Aug Link to this post

    Hello Peter,

    Thank you for writing. 

    Since Q2 2010 RadDropDownList was introduced which replaced the RadComboBox. That is why you couldn't find it in the toolbox. Additional information is available here:

    However, you can use simple data binding with RadTextBox. Here is demonstrated a sample code snippet which result is illustrated in the attached gif file. 
    private void Form1_Load(object sender, EventArgs e)
        this.radListView1.DataSource = this.customersBindingSource;
        this.radListView1.DisplayMember = "ContactName";
        this.radListView1.ValueMember = "CustomerID";
        this.radTextBox1.DataBindings.Add("Text", this.customersBindingSource,
            "ContactName", true, DataSourceUpdateMode.OnPropertyChanged);

    I hope this information helps. Should you have further questions I would be glad to help.

    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top
DevCraft R3 2016 release webinar banner