Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 672
Abhi Avatar asked Jul 29 '10 04:07

Abhi


People also ask

How display millions of records in GridView in ASP NET MVC?

You can store the record index in viewstate or in hidden fields run at = server. So, while you first load, set the pageindex to 0 and say you display 20 records. When the next is clicked, update the page index (pageindex++). Say when you click 8th page, set the page index to 8 and so on.

How fetch data from database and display in table in ASP NET MVC?

From the Add New Item window, select ADO.NET Entity Data Model and set its Name as NorthwindModel and then click Add. Then the Entity Data Model Wizard will open up where you need to select EF Designer database option. Now the wizard will ask you to connect and configure the Connection String to the database.


1 Answers

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

like image 157
15 revs, 2 users 83% Avatar answered Oct 01 '22 16:10

15 revs, 2 users 83%