2
Answers

transfer multiple items from one list to another list.

manjeev verma

manjeev verma

11y
892
1

i want to select multiple items in list1 and that selected items to be transfer in list 2 and store in sql table.
Answers (2)
0
Riyaz Akhtar

Riyaz Akhtar

NA 1.6k 318.2k 11y
try this

            foreach (ListItem val in ListBox1.Items.Cast<ListItem>().Where(val => val.Selected))
            {
                ListBox2.Items.Add(val);
            }

0
Sanjeeb Lenka

Sanjeeb Lenka

NA 22.1k 1.3m 11y
try like this:


if (ListBox1.Items.Count > 0)
{
for (int i = 0; i < ListBox1.Items.Count; i++)
 {
if (ListBox1.Items[i].Selected)
 {
string selectedItem = ListBox1.Items[i].Text;
 //insert command
ListBox2.Items.Add(selectedItem);
 }
}
}