Filter Data Table on Row position

I need to filter a data table on row position, e.g all rows before row 10 i.e positions 1-9 (this value will change each time filter is done) , how would I do that?

Hi @gurdev.singh

Can you try this

RowPosition = 9
FinalDT = InputDT.AsEnumerable.Take(RowPosition).CopyToDataTable

Regards,

@gurdev.singh,

Share some example how you want it.

Hi @gurdev.singh ,
Use below syntax
dt=dt.AsEnumerable().Skip(n).Take(m).CopyToDataTable()

Skip(n): Skips the first n rows.

Take(m): Takes the next m rows after skipping.

Regards,
Arivu

1 Like