Wondering anyone here can shed some light on this problem I'm having. I'm populating a listbox with items from a database - all have different text, but some have same values.
When the OnSelectedIndexChanged event fires, it registers the wrong item in the list as having been selected; if I select item 3 in the list, it thinks item 1 has been selected. I've never had this problem before and I'm either missing something silly or it's something I just didn't understand.
Anyone have any ideas why it's insisting on selecting the wrong index?
When the OnSelectedIndexChanged event fires, it registers the wrong item in the list as having been selected; if I select item 3 in the list, it thinks item 1 has been selected. I've never had this problem before and I'm either missing something silly or it's something I just didn't understand.
Code:
....
//populating the listbox
DataTable dt = MethodThatGetsDataFromDB();
foreach(DataRow rows in dt.rows)
{
[INDENT]listBox1.Items.Add(new ListItem(rows["col1"].ToString(), rows["col2"].ToString());[/INDENT]
}
....
Anyone have any ideas why it's insisting on selecting the wrong index?
