ComboBox Loses Selection but inconsistently :S

5 posts, 1 answers
  1. Paul
    Paul avatar
    28 posts
    Member since:
    Feb 2012

    Posted 18 Sep 2012 Link to this post

    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...
  2. Paul
    Paul avatar
    28 posts
    Member since:
    Feb 2012

    Posted 19 Sep 2012 Link to this post

    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...
  3. Answer
    Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 21 Sep 2012 Link to this post

    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.
  4. Paul
    Paul avatar
    28 posts
    Member since:
    Feb 2012

    Posted 21 Sep 2012 Link to this post

    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...
  5. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 21 Sep 2012 Link to this post

    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.
Back to Top