Question

I currently have a Product List which is stored in a Hash-table on my page. My Page_Load() event calls a method which sends a number of web service requests and generates a Products List. Then the product list is databound to my ListView and all works well. The only problem is that i have to wait for the all the web service requests to complete before my page is loaded.

My question is the following: Consider the fact that the web service calls will return 300 Products. How would i go about databinding and displaying the fisrt service request(say the first 30 items) and then loading the rest of the Product items(the other web service requests) into the ListView as the requests complete. There will be an update panel and annimation while all the data loads.

The reason i want to do this is because it reduces the waiting time before the page is displayed and it gives the user something to look at while the rest of the products are being populated.

How would i go about doing something like this? I cant seem to find any info on the net for my specific problem.

Thanks

Was it helpful?

Solution

You are looking for "Paging". In order to use paging, you need to configure your List-/GridView Control and specify the Paging properties.

However, you also need to tell your Web-Services, that you only want to load the items for one page. Otherwise, you have a paging, but still loading all items.

Lets assume you have a List with all your customers.

You may have to extend your current Web Service interface from

public IEnumerable<Customer> GetAllCustomers();

to

public int GetAllCustomerCount();
public IEnumerable<Customer> GetAllCustomers(int itemsPerPage, int page);
  1. You need to know the total count of the query (but not actually load all of them)
  2. You need a way to fetch only the items you need for the current page.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top