How to the select top n rows from a datatable/dataview in ASP.NET? Currently I am using the following code, passing the table and number of rows to get the records. Is there
I just used Midhat's answer but appended CopyToDataTable() on the end.
CopyToDataTable()
The code below is an extension to the answer that I used to quickly enable some paging.
int pageNum = 1; int pageSize = 25; DataTable dtPage = dt.Rows.Cast().Skip((pageNum - 1) * pageSize).Take(pageSize).CopyToDataTable();