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?
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.
Followed your advice here & set only the selected property to TRUE & the options are selected but they do not show up in the control,seperated by delimiter, unless the user selects another item. Then they all show up in the control. Is there a method I need to run to make them show up in the control before they select any new ones? The snippet of my code is included below the image.
Here's my code:
SymSQLAdapter.Fill(SymDataset, "SymInstList") If SymDataset.Tables("SymInstList").Rows.Count() > 0 Then For Each RowIn As DataRow In SymDataset.Tables("SymInstList").Rows If RowIn.Item(1).ToString = "Other" Then Me.OtherSymList.Text = RowIn.Item(2).ToString Else
For Each ItemAdd As Infragistics.Web.UI.ListControls.DropDownItem In Me.SymptomList.Items If ItemAdd.Value = RowIn.Item(0).ToString Then ItemAdd.Selected = True End If Next End If Next End If