vivekshah
June 11th, 2007, 05:41 AM
Hi
I have an Web application in C#.
ON the form I have two list box say ListBox1 and ListBox2.
ListBox1 has items binded through an SQL query.
and I want to add the selected contents of ListBox1 to ListBox2 on the button click.
I tried and below is my code on button click.
for (int i = 0; i < ListBox1.Items.Count; i++)
{
if (ListBox1.Items[i].Selected == true)
{
ListBox2.Items.Add(ListBox1.Items[i]);
}
}
--------------------
and also tried
foreach(ListItem item inListBox1.Items)
{
if(item.Selected)
{
ListBox2.Items.Add(item);
}
}
On clicking the button selected values from ListBox1 is not moved to ListBox2..
I want to do it only through Server side code only....?
Any Idea where could be the problem
I have an Web application in C#.
ON the form I have two list box say ListBox1 and ListBox2.
ListBox1 has items binded through an SQL query.
and I want to add the selected contents of ListBox1 to ListBox2 on the button click.
I tried and below is my code on button click.
for (int i = 0; i < ListBox1.Items.Count; i++)
{
if (ListBox1.Items[i].Selected == true)
{
ListBox2.Items.Add(ListBox1.Items[i]);
}
}
--------------------
and also tried
foreach(ListItem item inListBox1.Items)
{
if(item.Selected)
{
ListBox2.Items.Add(item);
}
}
On clicking the button selected values from ListBox1 is not moved to ListBox2..
I want to do it only through Server side code only....?
Any Idea where could be the problem