Assume you have two ListBoxes ListBox1 and ListBox2 in your ASP.NET application. You like to move selected items from ListBox1 to ListBox2. Usee the below code.
you can move multiple items by selecting multiple items in list box. To do that you have to set the ListBox "SelectionMode" properties to "Multiple"
if (ListBox.Items.Count > 0 && ListBox.SelectedItem != null) { while (ListBox.Items.Count > 0 && ListBox.SelectedItem != null) { ListItem selectedItem = new ListItem(); selectedItem = ListBox.SelectedItem; selectedItem.Selected = false; ListBox2.Items.Add(selectedItem); ListBox1.Items.Remove(selectedItem); } }
you can move multiple items by selecting multiple items in list box. To do that you have to set the ListBox "SelectionMode" properties to "Multiple"
No comments:
Post a Comment