I have a ListView that I am databinding to a collection of objects something like this:
int total; List<Client> clientList = clientData.GetClients(criteria, pageNum, pageSize, out total); uxClientList.DataSource = clientList; uxClientList.DataBind();
Where the pageNum, pageSize and total parameters facilitate paging at the data access layer. So far so good.
Now I can throw a DataPager on the page, point it at the ListView and get a decent paging UX. There's a little more to it when you're binding programmatically instead of declaratively with a data source control, but the problem here is that DataPager expects that the entire result set is being retrieved each time, from which it should calculate pagination, so it sees the single page of results returned as the total available records and gets rendered as if there is only one page of results available. In other words, the above scenario works fine with DataPager if we switch to a non-paging version of GetClients:
List<Client> clientList = clientData.GetClients(criteria); uxClientList.DataSource = clientList; uxClientList.DataBind();
Obviously since our data access layer is kind enough to provide us with a method to retrieve a page at a time, this would be preferable to retrieving all records every time. It would be nice if we could explicitly inform DataPager of the total available records so it could still automatically create pagination output, but only require one page at a time to do so.
I haven't found an easy way to do this and I haven't turned up anything in searches. Admittedly I don't currently posses a deep understanding of the implementation of DataPager, so hopefully I'm overlooking something.