J
Jason L Lind
Hi, I have an ASP.NET 2.0 ListBox control which, due to the compex underlying
data and the fact that it inside a dynamically generated grid, I need to
manually data bind multiple items as selected to.
The following code is how I'd think you'd do it, but it does not work:
foreach (FieldData data in dicData[new KeyValuePair(this.m_strPrototypeId,
this.m_objField.FieldId)])
{
lstBox.Items[lstBox.Items.IndexOf(lstBox.Items.FindByValue(data.Value))].Selected = true;
}
This code does not result in any of the items being selected on render, even
though they are on my control. I've used similar code with .SelectedIndex on
a DropDown list and those bind fine....
Any ideas?
Thank you,
Jason Lind
data and the fact that it inside a dynamically generated grid, I need to
manually data bind multiple items as selected to.
The following code is how I'd think you'd do it, but it does not work:
foreach (FieldData data in dicData[new KeyValuePair(this.m_strPrototypeId,
this.m_objField.FieldId)])
{
lstBox.Items[lstBox.Items.IndexOf(lstBox.Items.FindByValue(data.Value))].Selected = true;
}
This code does not result in any of the items being selected on render, even
though they are on my control. I've used similar code with .SelectedIndex on
a DropDown list and those bind fine....
Any ideas?
Thank you,
Jason Lind