tags:

views:

145

answers:

3

Hello Everybody,

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?

+5  A: 

To implement this optimized data fetch you have to implement custom paging rather then to use grid view paging. and Use SQl to get only the rows that you want to show on a page not the whole data.

see links:

Custom paging

Custom Paging in Asp.net

Paging tons of data in GridView

Efficient Paging for GridView

How to get Specific rows From Table by Id Range

Paging Large Datasets in SQL Server

Azhar
+2  A: 

You can using custom paging in ASP.NET 2.0 datasets.

Also, checkout other ways of paging large datasets

desigeek
+1  A: 

If you are using Sql Server 2005+, you could try using the ROW_NUMBER Function to page the database as explained in this article:

Paging Records Using SQL Server 2005 Database - ROW_NUMBER Function

Xaisoft