Loop thru ListBox selected items?
-
Hi I have two list boxes and two buttons: Add, Remove. Loading the 1st listbox in Page Load. Add button adds those items to 2nd box, which are selected in Ist one. 1. How do I loop through Ist one? 2. Also, I need to check that item is not there in 2nd before adding it. 3. Also, I need to remove it from Ist list box. Please advice. Thanks Follow your goals, Means will follow you ---Gandhi---
-
Hi I have two list boxes and two buttons: Add, Remove. Loading the 1st listbox in Page Load. Add button adds those items to 2nd box, which are selected in Ist one. 1. How do I loop through Ist one? 2. Also, I need to check that item is not there in 2nd before adding it. 3. Also, I need to remove it from Ist list box. Please advice. Thanks Follow your goals, Means will follow you ---Gandhi---
protected void Add( object obj, CommandEventArgs args ) { ArrayList tmp = new ArrayList(); for( int i = 0; i < lstBox1.Items.Count;i++ ) { if( lstBox1.Items[i].Selected ) { lstBox2.Items.Add( listBox1.Items[i] ); tmp.Add( lstBox1.Items[i] ); } } for( int i = 0; i
for the remove change lstBox1 to listBox2 you should have to worry about duplicate because if you remove the items from lstBox1 after added them to lstBox2 you can't add a duplicate no guarentees on this code. i just whipped this up joe
-
Hi I have two list boxes and two buttons: Add, Remove. Loading the 1st listbox in Page Load. Add button adds those items to 2nd box, which are selected in Ist one. 1. How do I loop through Ist one? 2. Also, I need to check that item is not there in 2nd before adding it. 3. Also, I need to remove it from Ist list box. Please advice. Thanks Follow your goals, Means will follow you ---Gandhi---
Check out my free DualList control.