while processing the items in a listbox foreach loop, the if (item.selected) never finds expected row(s)
The foreach is looping thru the data as expected.
The foreach is looping thru the data as expected.
Code:
<asp:ListBox runat="server" ID="lstFrom" Width="250" Height="200" SelectionMode="Multiple"></asp:ListBox> <asp:ListBox runat="server" ID="lstTo" Width="250" Height="200" SelectionMode="Multiple"></asp:ListBox> protected void btnSelectOne_Click(object sender, EventArgs e) { MoveSelectedItem(lstFrom, lstTo); } private void MoveSelectedItem(ListBox fromListBox, ListBox toListBox) { List<ListItem> selected = new List<ListItem>(); foreach (ListItem item in fromListBox.Items) { if (item.Selected) selected.Add(item); // this is not being hit } }
Comment