RadDropDownList

11 posts, 0 answers
  1. Mehdi Mirza
    Mehdi Mirza avatar
    11 posts
    Member since:
    Apr 2009

    Posted 01 Dec 2010 Link to this post

    hello,

    I am using RadDropDownList and binding it in Code behind using a datatable. The issue is when the form loads the RadDropdownlist displays the first record in the list and this fires the selectedindexchanged.
    I want the RadDropDownlist to be in the state where the user selects the item he wants from the list and then the selectedindexchanged event fires.

    Any ideas?

    Thanks

  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 02 Dec 2010 Link to this post

    Hello,

    The RadDropDownList will always show the first item, unless you speciifically set it to something else. In my view, it's not normal winforms practice to provide a blank entry as the first item that the user can deselect, and then go back to again. If you really need to have a default item, then this should be added to the datasource.

    I hope this helps but let me know if you need more help.
    Richard

  3. Mehdi Mirza
    Mehdi Mirza avatar
    11 posts
    Member since:
    Apr 2009

    Posted 05 Dec 2010 Link to this post

    Hello Richard,

    I disagree with your input, the Rad dropdown if i manually bind it using a datatable then it displays the first record, but if i am using dataset on the form itself and not code behind then it populates the rad dropdown leaving an empty selection at top.

    thanks

    Mehdi

  4. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 05 Dec 2010 Link to this post

    Hello,

    If you must have a default option, then you can use the following after binding the data

    this.radDropDownList1.SelectedIndex = -1;
    this.radDropDown1.Text = "Please Select A Value";

    hope that helps
    richard

  5. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 07 Dec 2010 Link to this post

    Hello, 

    Did this help? If so, please mark as answer so others can find the solution too. 
    Thanks
    Richard

  6. black
    black avatar
    2 posts
    Member since:
    Dec 2010

    Posted 28 Dec 2010 Link to this post

    Richard Slade Thanks it worked for me
    _________________________
    Check out residual affiliate programs and get recurring money.

  7. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 28 Dec 2010 Link to this post

    glad that worked for yuo. Please remember to mark as answer,
    Richard

  8. Peter
    Admin
    Peter avatar
    1143 posts
    Member since:
    Sep 2012

    Posted 29 Dec 2010 Link to this post

    Hi Mehdi Mirza, I am glad to hear that Richard's solution works for you. By default the first record is selected when using data-bound RadListControl or RadDropDownList and this desired behavior causes the issue. 

    Should you have any other questions, do not hesitate to write back.

    Kind regards, Peter
    the Telerik team

    Get started with RadControls for WinForms with numerous videos and detailed documentation.

  9. Bruno
    Bruno avatar
    3 posts
    Member since:
    Dec 2010

    Posted 18 Mar 2011 Link to this post

    I notice that the SelectedIndexChanged event of the radDropDownList is also fired when I call the Clear() method.

    How can I know if the SelectedIndexChanged was fired from Clear() and not from a user selecting another listitem so I can condition my event code on it?

    I can answer this question myself, but I don't like my solution: when coming from Clear() the radDropDownListWorkfolders:Items:Count is equal to 0. But that's not really clean, is it?

  10. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 18 Mar 2011 Link to this post

    Hello Bruno,

    Another way might be to not fire the event when you clear the items by removing and re-adding the event handler before and after the clear().
    Hope that helps
    Richard

  11. Peter
    Admin
    Peter avatar
    1143 posts
    Member since:
    Sep 2012

    Posted 23 Mar 2011 Link to this post

    Hello,

    Yes, it is a desired behavior, because Items.Clear removes all items, hence there are no selected items. As a result, the SelectedIndexChanged should be fired.

    You can also put Items.Clear in BeginUpdate/EndUpdate block.

    I hope this helps.

    Regards,
    Peter
    the Telerik team

Back to Top