Hi, My question is probably a simple one to people used to ASP.NET, So here it is: I have a webform in a master page that has a listbox which populates itself with numbers which serve as unique id for my objects.
The only problem is that the selected index property of the listbox is always -1 and it automatically deselects itself, no matter what I select. I understand that the index is -1 when you havent selected anyhting, but I have. Here is my C# code that I used to test it and my ASP.NET code:
protected void List_SelectedIndexChanged(object sender, EventArgs e)
{
MessageBox.Show(List.SelectedIndex.ToString());
MessageBox.Show(List.Items[2].ToString());
}
I use the first message box to see what the selected index is and the second to check my 3rd items in the listbox is being recognised.
<asp:ListBox ID="List" runat="server" AutoPostBack="true"
EnableViewState="true"
onselectedindexchanged="List_SelectedIndexChanged"></asp:ListBox>