what is the easiest way to select top 20 rows from a datatable ?

  • Thread starter Thread starter Ersin Gençtürk
  • Start date Start date
I mean selecting from datatable , you know asp.net datatable object , not
from database table!
 
It never works !!! DataTable.Select() works as a where clause...

I assume SourceTable contains whole data and u don't need to sort it.

DataTable outputTable = SourceTable.Clone();
for(int i=0;i<20;i++)
outputTable.ImportRow(SourceTable.Rows);

outputTable contains top 20 records.
 
thanks yunus ,

already this is the way that I am doing it.I think there is no other way to
do it with dataview.

Yunus Emre ALPÖZEN said:
It never works !!! DataTable.Select() works as a where clause...

I assume SourceTable contains whole data and u don't need to sort it.

DataTable outputTable = SourceTable.Clone();
for(int i=0;i<20;i++)
outputTable.ImportRow(SourceTable.Rows);

outputTable contains top 20 records.

--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

BillGatesFan said:
dr() = datatable.select ("select Top 20 from tblorders")
 
Back
Top