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

ComboBox Loses Selection but inconsistently :S

4 Answers 71 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Iron
Paul asked on 18 Sep 2012, 09:09 PM
So, I have 2 comboboxes in a sort of master/detail scenario.  The "detail" combobox is losing it's selected item, but only in one case as far as I can see.  In other words, if the Master selection is say A,B or C... the Detail combobox is fine, but if the Master selection is D, the Detail combobox resets to the first item (I think as soon as it loses focus).  Any thoughts?


EDIT: OK, narrowed it down some although still wierdddddddd.  In the index changed event, I'm handling a UI feature, basically setting an element's visibility based on the value of a property in the selected item.  And if that "if" is true, the element is set visible and the selected item resets.  Enough for today...

EDIT, AGAIN:  OK, so it isn't the UI update that's causing it.  Somehow the value of this property in the dataset is the key but not anything that's set because of it.  Maybe the two LINQ queries are interacting in some bizaare way.  Tomorrow's another day...

4 Answers, 1 is accepted

Sort by
0
Paul
Top achievements
Rank 1
Iron
answered on 19 Sep 2012, 03:08 PM
OK, solved the problem although I still don't "get it" but I thought I'd post it here for others.  In my combobox, I had the datavalue set to a bool, because I wanted to flip a UI element based on the value for the given selected item.  Here's where it gets wierd.  If I run a query that populated the combobox with results ALL of whose bools were false, the selection wouldn't "hold", and reset to the index[0] item immediately.  If any one of the results had a member whose bool was true, the combobox worked as expected.  I thought maybe there was a wierd event happening when I triggered my UI change but that wasn't it.  So, I had to change the datavalue and then hit the db with another query that returned the bool I needed.  Sadly, it's pretty inefficient but it works :S


Hope this helps someone else...
0
Accepted
Ivana
Telerik team
answered on 21 Sep 2012, 10:52 AM
Hi Paul,

The values set to the items in the Items collection of RadComboBox need to be unique for every item for this is the value which identifies an item. Setting the same value to more than one item will result in inconsistent selection of the items. 

I hope the information provided will be helpful to explain the weird behavior with RadComboBox selection.

Regards,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Paul
Top achievements
Rank 1
Iron
answered on 21 Sep 2012, 11:09 AM
Thanks for that Ivana.  I was never aware that it had to be a unique identifier.  Is that the case for other controls?  I'd always assumed that variables that needed to be unique had names that implied that, such as key or ID...
0
Ivana
Telerik team
answered on 21 Sep 2012, 02:54 PM
Hello Paul,

Yes, this is the case with the values assigned to the items in most of the RadControls for ASP.NET AJAX. If the situation is different for some controls it should be stated in the documentation.

Regards,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ComboBox
Asked by
Paul
Top achievements
Rank 1
Iron
Answers by
Paul
Top achievements
Rank 1
Iron
Ivana
Telerik team
Share this question
or