MCRoberts
September 15th, 2008, 02:30 PM
Greetings:
I have a simple ListBox with multiselect enabled in an ASP.NET 2.0 WEB project. The box has about 10 items in it and to test, I selected items 1 and 5 (index base 0). Both items in the box are highlighted as you would expect. Also, I checked to ensure that view state was enabled for the list box.
Then, I execute this code straight out of MS-help to determine which items where selected:
int nNumSel = 0;
foreach(ListItem li in ListBox1.Items)
{
if(li.Selected == true)
{
nNumSel++;
}
}
Stepping through this, I am finding that only the 1st selected item is recognized as being selected. The item at index 5 is reporting "false" for its "Selected" property. Why? What have I missed?
Thanks to anybody that responds.
Mark
I have a simple ListBox with multiselect enabled in an ASP.NET 2.0 WEB project. The box has about 10 items in it and to test, I selected items 1 and 5 (index base 0). Both items in the box are highlighted as you would expect. Also, I checked to ensure that view state was enabled for the list box.
Then, I execute this code straight out of MS-help to determine which items where selected:
int nNumSel = 0;
foreach(ListItem li in ListBox1.Items)
{
if(li.Selected == true)
{
nNumSel++;
}
}
Stepping through this, I am finding that only the 1st selected item is recognized as being selected. The item at index 5 is reporting "false" for its "Selected" property. Why? What have I missed?
Thanks to anybody that responds.
Mark