How to select top n rows from a datatable/dataview in asp.net
Posted
by skamale
on Stack Overflow
See other posts from Stack Overflow
or by skamale
Published on 2010-05-07T09:18:16Z
Indexed on
2010/05/07
9:28 UTC
Read the original article
Hit count: 319
How to select top n rows from a datatable/dataview in asp.net.currently I am using the following code by passing the table and number of rows to get the records but is there a better way.
public DataTable SelectTopDataRow(DataTable dt, int count)
{
DataTable dtn = dt.Clone();
for (int i = 0; i < count; i++)
{
dtn.ImportRow(dt.Rows[i]);
}
return dtn;
}
© Stack Overflow or respective owner