Hi, I want to copy the row to the new dataset if the previous value in second column isn't the same as the current one (i.e this dataset should have rows with unique values):
DataTable tbl = new DataTable();
DataTable tmpTable = ds.Tables[0];
for( var rowIndex = 0; rowIndex < ds.Tables[0].Rows.Count; rowIndex++ )
{
object value = null;
foreach (DataRow x in tbl.Rows)
{
if (ds.Tables[0].Rows[rowIndex][1] == x[1])
{
value = ds.Tables[0].Rows[rowIndex][1];
break;
}
}
// value already exists
if (value == null)
{
tbl.ImportRow(ds.Tables[0].Rows[rowIndex]);
}
}
How to do this correctly? Maybe one loop instead 2?