Hi,
Rows is a collection you CANNOT modify any collection while being iterating.
what you can do is keep a reference to the rows you want to delete:
ArrayList todelete = new ArrayList();
foreach(row in table1)
{
string key = row[columnname];
foreach(row1 in table2)
{
if (row1[columnname].tostring().equals(key))
todelete.Add( row1);
}
}
foreach( row in todelete )
table2.Rows.Delete( row)
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"DBC User" <db*****@gmail.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
>I would like to delete a row from a dataset based on a condition. Here
is what I am doing
foreach(row in table1)
{
string key = row[columnname];
foreach(row1 in table2)
{
if (row1[columnname].tostring().equals(key))
row1.delete();
}
}
[I made it simple and please ignore the syntax, I have to code
correct]. right adter I do row1.delete on the next foreach loop of
table2, the program throws an exception saying the collection is
changed. How can I delete a row in table2 based on values from table1?
Thanks in advance.