I have 2 listboxes in my application. The data is being retrieved from a SQL server database. In listbox1, I want to select few items from this listbox and add them to second one through add button.
PROBLEM: The values are being retrieved from the database but when I click the add button after selecting a value from listbox1, System.Data.DataRowView is displayed in listbox2 automatically.
Listbox2 is not currently connected to any databse.
Here is the code:
for (int i = 0; i < listBox1.Items.Count; i++)
{
listBox2.Items.Add(listBox1.Items[i]);
listBox1.Items.Remove(listBox1.SelectedItem);
}
I have also tried using this:
for (int i = 0; i < from.SelectedItems.Count; i++)
{
to.Items.Add(from.SelectedItems[i].ToString());
}
foreach (var item in new ArrayList(from.SelectedItems))
{
from.Items.Remove(item);
}
From and to are listbox1 and listbox2 respectively.
Any help would be appreciated.