L
laurasaur
Hi everyone,
I have 2 listboxes that I need to move items between, they are both
bound to DataTables which get populated from the database with a list
of clients.
Im getting a few problems, with remove I am getting
InvalidArgument=Value of '0' is not valid for 'SelectedIndex'.
Parameter name: SelectedIndex
and sometimes when I try and add items that were previously not there
I get
"Deleted row information cannot be accessed through the row"
private void btnAdd_Click(object sender, EventArgs e)
{
//Add Clicked
List<DataRow> selectedrows = new List<DataRow>();
foreach (DataRowView row in
listAvailableClients.SelectedItems)
{
selectedClients.ImportRow(row.Row);
selectedrows.Add(row.Row);
}
foreach (DataRow row in selectedrows)
{
row.Delete();
}
}
private void button2_Click(object sender, EventArgs e)
//If remove clicked
{
List<DataRow> selectedrows = new List<DataRow>();
foreach (DataRowView row in
listSelectedClients.SelectedItems)
{
availableClients.ImportRow(row.Row);
selectedrows.Add(row.Row);
}
foreach (DataRow row in selectedrows)
{
row.Delete();
}
}
I know this has something to do with the CurrentRow properties of the
DataView but I can't really get my head around it ;p
Thanks heaps for any help,
Laura, NZ
I have 2 listboxes that I need to move items between, they are both
bound to DataTables which get populated from the database with a list
of clients.
Im getting a few problems, with remove I am getting
InvalidArgument=Value of '0' is not valid for 'SelectedIndex'.
Parameter name: SelectedIndex
and sometimes when I try and add items that were previously not there
I get
"Deleted row information cannot be accessed through the row"
private void btnAdd_Click(object sender, EventArgs e)
{
//Add Clicked
List<DataRow> selectedrows = new List<DataRow>();
foreach (DataRowView row in
listAvailableClients.SelectedItems)
{
selectedClients.ImportRow(row.Row);
selectedrows.Add(row.Row);
}
foreach (DataRow row in selectedrows)
{
row.Delete();
}
}
private void button2_Click(object sender, EventArgs e)
//If remove clicked
{
List<DataRow> selectedrows = new List<DataRow>();
foreach (DataRowView row in
listSelectedClients.SelectedItems)
{
availableClients.ImportRow(row.Row);
selectedrows.Add(row.Row);
}
foreach (DataRow row in selectedrows)
{
row.Delete();
}
}
I know this has something to do with the CurrentRow properties of the
DataView but I can't really get my head around it ;p
Thanks heaps for any help,
Laura, NZ