Using DataPager without retrieving all rows for each query

I have a ListView that I bind to a collection of objects like this:

int total; List<Client> clientList = clientData.GetClients(criteria, pageNum, pageSize, out total); uxClientList.DataSource = clientList; uxClientList.DataBind(); 

In cases where the pageNum, pageSize and total parameters facilitate swapping at the data access level. So far so good.

Now I can drop the DataPager on the page, point it to the ListView and get a decent paging UX. There's a bit more when you bind programmatically, rather than declaratively, with data source control , but the problem is that the DataPager expects the entire result set to be retrieved each time from which it should calculate the pagination, so it sees a single page of results returned as common available records, and gets rendered as if only one page of results was available. In other words, the script described above works fine with the DataPager if we move to the GetClients version without paging:

 List<Client> clientList = clientData.GetClients(criteria); uxClientList.DataSource = clientList; uxClientList.DataBind(); 

Obviously, since our level of data access is kind enough to provide us with a way to retrieve a page at a time, it would be preferable to get all the records every time. It would be nice if we could explicitly inform the DataPager of the available records available so that it can automatically generate pagination output, but this only requires one page.

I did not find an easy way to do this, and I did not find anything in the search. Admittedly, at the moment I do not understand a deep understanding of the implementation of DataPager, so I hope I'm missing something.

+4
source share
2 answers

You have not missed anything.

When working with large result sets, you need to disable paging and add your own alert elements.

In my experience, <<β†’> that's enough. In any case, no one goes for the third page.

+2
source

Look at the ListViewPagedDataSource and its AllowServerPaging property, I think it might be what you are "Looking for."

+3
source

All Articles