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

  • Thread starter Ersin Gençtürk
  • Start date
E

Ersin Gençtürk

I mean selecting from datatable , you know asp.net datatable object , not
from database table!
 
Y

Yunus Emre ALPÖZEN [MCAD.NET]

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.
 
E

Ersin Gençtürk

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")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top