Serge
Serge

Reputation: 35

How to filter only first row of dataview

I have a dataview object in asp.net 3.5, and I need to put a filter on it in such way that I only keep the first row on the dataview. I've searched for ways to do this, but so far no luck. The .RowFilter property only seems to work with WHERE criteria, and that is not what I am looking for. I just need to eliminate all rows except the first one.

Upvotes: 0

Views: 1673

Answers (1)

Enrique Zavaleta
Enrique Zavaleta

Reputation: 2108

In the comments I can see you have this statement

dv.table = sourceTable;

just do this to get the first row

dv.Table = (new DataRow[] { sourceTable.AsEnumerable().ElementAt(0) }).CopyToDataTable();

Upvotes: 1

Related Questions