Search code examples
asp.netvb.netpagination

How should I display datatable in multiple pages?


I have an ASPX page (vb.net code-behind) with a textbox and a button. Clicking the button will load the result based on the parameter the user specified in the textbox. The problem is if the result is too much, the page is too slow to load.

Which is the better option to improve performance:

  1. Load the page in chunks, and as the user scrolls more results will be displayed. If so, where do I start reading and how do I do it?

  2. Pagination for, say, 10 records at a time, with additional elements in the page such as next page or previous page buttons.

  3. A "loading" progress bar that shows, "Loading .. 10% done, 20% done.. 100% done.. Then at least the user is not just watching the spinning icon in their browser.


My site also has a function that loops through a datatable (DT). Lets call this function displayImages(). DT holds a set of file names, and may have 200 records.

The displayImages() function determines where the file is located and displays the result to the user. The end result is HTML tag like

<img src="path/filename.jpg" />

The problem I am currently having is the function is too slow to complete all 200 results. My attempt to give the user some feedback to show where the loop is at have not worked very well. I don't know how to make a nice progress bar to show end user what the loop is doing inside the function.

So I have this idea to show only 10 records at a time, and a user then clicks a link button or ASPX button for page 1 , page 2 and so on, to display the next results.

I read I can use pagingdatasource, but I am wondering if there is a clever way to just loop the datatable from row 1 to 10, then row 11 to 20, and so on...

I guess my problem is how can I keep that datatable in memory so I can keep referring to it.

How can I do this? Any suggestions or help is appreciated.


Solution

  • In the end I end up with option number 2.

    I am not using sql data source in my code. but I only use datatable.

    so to achieve option 2 (which is to display 10 records at one time. and the user has the ability to click page 1 page 2 page 3) I use gridview and css.

    Gridview is set to display 10 results at one time.

    And as the gridview is irrelevant for the user I use CSS to hide all the contents. but only show the pagination row (the last row)

    as I am learning to code in asp.net and vb.net I wish to be able to do option 1 or option 3. I am hoping I will be able to learn how to do it in the near future.

    Thanks!