I have a listbox that's values populate from a SQL datasource. In the form on the page there is also a drop down list and when it's value changes the items in the listbox change accordingly (well, technically, it changes a sql parameter that updates the listbox).
In another SQL query I have a list of values separated by commas. I then turn that into a string array. The values in that string array correspond to values in the listbox I'd like selected. This is where I'm running into trouble - how do I get the listbox items to be selected? I believe the trouble I'm running into is when to run the proceedure, I've tried in the page load, databound, text changed, selecting - I can't seem to find where to put it so that it checks after the listbox is updated with the SQL info.
// SelectedItem is my string array
for (int i = 0; i < SelectedItem.Length; i++)
myListbox.Items.FindByValue(SelectedItem[i].ToString()).Selected = true;