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
495
Selecting items programmatically with multi select webdropdown
posted

I can select items programmatically by using this code:

                foreach (DropDownItem item in webDropDownIndustriesNotAcceptingSolicitations.Items)
                {
                    item.Selected = true;
                    webDropDownIndustriesNotAcceptingSolicitations.SelectedItems.Add(item);
                }

All of the checkboxes are selected when I bring the dropdown list up. But the item displayed in the control does not reflect the items selected in the list. If I manually uncheck one of them then the whole list shows up as a comma delimited list. How do I cause the selected list to be reflected in the control?

Parents
No Data
Reply
  • 12025
    posted

    Hello David, 

    You don't need to explicitly add items ot the selected items collection. Once you set the item select to true, the selected items collection will automatically add it to the collection. 

    webDropDownIndustriesNotAcceptingSolicitations.SelectedItems.Add(item); /// not required

    -Taz. 

Children