Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
225
WebDropDown Save and restore selected item.
posted

Hello again....

I have a a WebDropdown that has been loaded with data from a table. What are the properties that I need to use to get and restore the selected item in the WebDropdown.

 

Parents
No Data
Reply
  • 24671
    posted

    Hi,

    The selected item is automatically stored in the SelectedItem WebDropDown property. If you have EnableMultipleSelection=true, you need to use the SelectedItems collection :

    1)

    WebDropDown1.SelectedItem

    2)

    WebDropDown1.SelectedItems

    You  do not need any special code / logic to store and restore the selection across postbacks -  it is done automatically.

    In order to set an Item as selected, you can do :

    WebDropDown1.Items[0].Selected = true; //  this will mark the first item as selected 

    For single selection you can also do :

    WebDropDown1.SelectedItem = item;

    Thanks,

    Angel 

Children