0

I'm working on a web page that should display huge amounts of data in a GridView. Obviously I would use some sort of paging.

What I want to know is the best way of doing such a thing, what is the norm?

Should I connect to database each time for every page of GridView? Should I connect to database one time for the first page and load the rest of the data in some kind of background task? Should I load a few pages of data in advance, in the background, to lessen users waiting time?

Any advice is appreciated.

Do keep in mind I'm relatively new to programming and thank you!

  • 1
    Answer to all your questions: it depends. You can connect to database for every page, or based on how often your data updated you can keep cash of data already fetched from database. And solution will depends on the usage of your software. So my suggestion is start with loading paging. Then another point - do you really need to show all data to the user? – Fabio Nov 24 '16 at 10:39

3 Answers3

0

Just compare the probability of getting full set of your data for your users first to choose appropriate solution:

  • if the chance that user need your second page not a big (last news, relevant search results, etc) - do not load all your data. Just load first page only.

  • if your data are processes sequentialy and they are dependent, so you really know taht after first page user should/must proceed to next page - review solution to load your data for next page in backgroud thread while user works with data of current page (process tasks or documents, approve orders, etc).

  • if your solution means - your users can randomly navigates to pages in your grid and do this very often (each user need to visit at least several pages randomly) - review solution to load all data into cache and generate pager using cached local data.

Hope this helps.

VadimB
  • 5,533
  • 2
  • 34
  • 48
0
  1. Use virtualization of Control you use - any grid or lists! Thats important and #1

  2. Set a middle-tier service, that helps you to loads from DB only visible +/- few rows up and down. You can do it via cursors in query, or a much simpler via LINQ extensions wirh .Skip(count) and Take(count) -- that can helps you how many rows you realy read from which position of set (or you can see with LinqPad how it can be transformed in T-SQL if you don't use any ORM)

  3. Don't sort or filter your set on Control (grid or listvew), do it via query on DB side - its a lot times faster(!) with their indexes in DB

0

Use a SQL Server stored procedure for fetch huge data also send 2 extra parameter paging Page Number, Page Size and return total count from procedure.

Pagination with the stored procedure

Community
  • 1
  • 1
ADNAN ZAMAN
  • 68
  • 1
  • 10