Reputation: 1271
I have a huge table and I need to implement a (web) control to allow me to browse through all records, paginate, filter and sort them. My first thought is to implement a DataGrid/something and to put as DataSource a DataTable which is read (with a "view" or simple sql "select all" statement) and then to filter the DataTable object (DataView.RowFilter, etc). As far as I am aware, this sorting/filtering is done on the client-side, after all records are read. Is there any more elegant/efficient way to do this (meaning - just read the records you need from the database server)?
Upvotes: 0
Views: 310
Reputation: 2726
For controls like GridView the default paging retrieves all rows from the database each time a page is selected.
Not exactly efficient is it? However, you can use custom paging to retrieve only those records you need for the currently selected page.
Here is an example: http://www.asp.net/web-forms/tutorials/data-access/paging-and-sorting/efficiently-paging-through-large-amounts-of-data-cs
Upvotes: 1