This is a migrated thread and some comments may be shown as answers.

Weird behaviour with DataBinded RadComboBox

6 Answers 116 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Stargazer
Top achievements
Rank 2
Stargazer asked on 28 May 2008, 11:08 AM
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"); 

6 Answers, 1 is accepted

Sort by
0
Stargazer
Top achievements
Rank 2
answered on 29 May 2008, 08:35 AM
Anyone? No ideas?
0
Stargazer
Top achievements
Rank 2
answered on 30 May 2008, 02:55 PM
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?
0
Georgi
Telerik team
answered on 30 May 2008, 04:19 PM
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
0
Stargazer
Top achievements
Rank 2
answered on 30 May 2008, 04:59 PM
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...
0
Accepted
Georgi
Telerik team
answered on 02 Jun 2008, 02:15 PM
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
0
Stargazer
Top achievements
Rank 2
answered on 02 Jun 2008, 02:41 PM
Oh well... Can't believe I missed that one in all the dozen of tests I made... Thanks!
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Stargazer
Top achievements
Rank 2
Answers by
Stargazer
Top achievements
Rank 2
Georgi
Telerik team
Share this question
or