How to filter datatable by his indexRow with method Select()


I have a datatable dt_DT1 wich contains 4 columns and 3 rows.
I want to replace all the contains of DT1 with only one row.
The row that I want is the next of the row with value ‘‘3’’


Column1 Column2 Column3
1 2 3
4 5 6
7 8 9

The unique value that doesnt change is ‘‘3’’ all of the rest change always. So I have to filtered first by the value 3, the increment the index row to extract the next datarow and replace the original datatable with only that datarow

Final result:

Column1 Column2 Column3
4 5 6

So do you know guys how to filter with the row index in Select method?
something like this:

dt_DT1.Select("[RowIndex]"=‘int_rowIndexValue3 + 1’).CopyToDataTable


The syntax used within the select method does not offered such a identifier.

As an alternate we can retrive with a LINQ

idx = 
YourDataTableVar.AsEnumerable.toList.FindIndex(Function (x) x(ColNameOrIndex).toString.Equals("3"))

in case we want to check in all columns we can do:

YourDataTableVar.AsEnumerable.toList.FindIndex(Function (x) x.itemArray.Any(Function (i) i.toString.Equals("3"))

when idx is not -1 we can do
dt_DT1 =
dt_DT1.AsEnumerable.Skip(idx +1).Take(1).CopyToDataTable

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.