Search code examples
c#asp.net.netgridviewdetailview

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


In ASP.net when we perform paging over Gridview or DetailsView than the Gridview fetch all rows from the Database each time.

Suppose our Database contains 100 rows and we have configured Paging in Gridview with page size of 10 records per page.But whenever we click on the the pager control of gridview for any particular page no. then GridView should fetch only particular 10 rows from database.

If we click on page no 3 then it should query only rows 21-30 but it fetches all rows and neglect the remaining .which is simply a wastage of resources.

Can any one of please suggest me a solution to this problem?


Solution

  • To implement this optimized data fetch, you have to implement custom paging (rather than using the GridView paging). Also, you should use SQL to get only the rows that you want to show on a page (not all of the data).

    See the following related links:

    Custom Paging in Asp.net

    Paging tons of data in GridView

    How to get Specific rows From Table by Id Range

    Paging Large Datasets in SQL Server