How to increase efficiency of GridView or DetailsView in ASP.NET?

In ASP.net, when we pager on a Gridview or DetailsView than Gridview, we retrieve all the rows from the database each time.

Suppose our database contains 100 rows and we set up paging in Gridview with a page size of 10 records per page. But whenever we click on the gridview pager control for any particular page, no. then GridView should display only certain 10 rows from the database.

If we click on page number 3, then he should request only lines 21-30, but he will extract all the lines and ignore the rest. It is simply a loss of resources.

Can any of you suggest me a solution to this problem?

+5
source share
3 answers

To implement this optimized data selection, you need to implement custom paging (rather than using GridView swap). In addition, you should use SQL to get only the rows that you want to show on the page (not all data).

See the following links:

User Paging at Asp.net

Paging tons of data in a gridview

How to get specific rows from a table by range of identifiers

Paging Large Datasets in SQL Server

+7
source
+3

If you are using Sql Server 2005+, you can try using the ROW_NUMBER function to create the database, as described in this article:

Paging Entries Using SQL Server 2005 Database - Function ROW_NUMBER

+2
source

All Articles