Weird behaviour with DataBinded RadComboBox

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

    Posted 28 May 2008 Link to this post

    Hello!

    I'm having a strange issue in my application. My scenario is as follows:

    1. I have a simple form, with a RadComboBox and a TextBox;
    2. I have a custom object (say myObject);
    3. I bind my RadComboBox to a DataTable, using a BindingSource;
    4. I had a binding to the RadComboBox from SelectedValue to a property of myObject;

    The problem is that whenever I select an item from de RadComboBox (DropDownList mode), and then I leave the combo changing the focus elsewhere, the combo becomes unselected. I tried the same with the normal ComboBox and it works flawlessly.

    Any thoughts on this one? Many thanks in advance!

    My code, at Form Load:
    cmbTipoCriterioPai.BindingContext = new BindingContext(); 
     
    // Populating the BindingSource 
    ServicoTipoCriterio servicoTipoCriterio = new ServicoTipoCriterio(); 
    bsPais.DataSource = servicoTipoCriterio.GetDadosPesquisa("0=0"); 
    servicoTipoCriterio.Dispose(); 
     
    // DataBinding the RadComboBox 
    cmbTipoCriterioPai.DisplayMember = "Designacao"
    cmbTipoCriterioPai.ValueMember = "ID_TipoCriterio"
    cmbTipoCriterioPai.DataSource = bsPais; 
     
    // Adding the SelectedValue DataBinding 
    cmbTipoCriterioPai.DataBindings.Clear(); 
    cmbTipoCriterioPai.DataBindings.Add("SelectedValue", myObject, "ID_TipoCriterioPai"); 

  2. Stargazer
    Stargazer avatar
    73 posts
    Member since:
    Jan 2007

    Posted 29 May 2008 Link to this post

    Anyone? No ideas?
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Stargazer
    Stargazer avatar
    73 posts
    Member since:
    Jan 2007

    Posted 30 May 2008 Link to this post

    Well... I managed to narrow down my testings to a point where I noticed that the same data, on two different databases and tables and servers, one scenario works great and other don't, being the only difference the collation on the table (inherited from server default, off course). Is there anything I'm doing wrong? Something I'm missing?
  5. Georgi
    Admin
    Georgi avatar
    212 posts

    Posted 30 May 2008 Link to this post

    Hi Stargazer,

    I have posted the answer to your support ticket. Here is the text:

    Leaving the RadComboBox fires the Validating event, which causes the change to be applied and perhaps this is followed by actions that lead to changing the SelectedValue property.

    Since your scenario is quite specific, please send us a sample application which reproduces the issue. It will help us investigate the causes of a potential issue, and address it faster.

    Please open a support ticket to be able to attach files. I'm looking forward to receiving your response.

    Sincerely yours,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Stargazer
    Stargazer avatar
    73 posts
    Member since:
    Jan 2007

    Posted 30 May 2008 Link to this post

    Georgi, thanks! I'll probably manage to get you a sample project during the weekend. Sorry for the persistence, but this has made me grow some new white air...
  7. Answer
    Georgi
    Admin
    Georgi avatar
    212 posts

    Posted 02 Jun 2008 Link to this post

    Hello Stargazer,

    I have posted the answer to your support ticket. Here is the text:

    I tested your application and reviewed it in details. It appears that the issue is not in the different collation but in the structure of the table itself. In the working example, the definition of the ID column of the table is as follows:

        [ID] [int] IDENTITY(1,1) NOT NULL,

    while in the one not working properly is as follows:

        [ID] [smallint] IDENTITY(1,1) NOT NULL,

    Since the MyBusinessObject.ID_FromComboTable is defined as an integer, this causes an invalid cast in the databinding mechanism of RadComboBox. As a result, the SelectedValue is set to null.

    I hope this helps. If you have any other questions, don't hesitate to write us again.

    Kind regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. Stargazer
    Stargazer avatar
    73 posts
    Member since:
    Jan 2007

    Posted 02 Jun 2008 Link to this post

    Oh well... Can't believe I missed that one in all the dozen of tests I made... Thanks!
Back to Top
UI for WinForms is Visual Studio 2017 Ready