Search code examples
vb.netdatapager

VB.Net using a Datapager with a source that already is paged


I'm looking for some advice on how to use a DataPager (with a listview) when the source already is paged. In my database I have a stored procedure already handling the paging for me. The output of that procedure is always the amount of rows I gave as a parameter.

When is use this on my datapager (with a listview) I always get one page because the amount of rows is equal to the datapagers pagesize.

Aside from my stored procedure I have the ability to get a number of all the rows in the table.

How can I manually tell my datapager the correct amount of pages. Or is there an other way to accomplish this?


Solution

  • After a bit more research i found out this is possible when you connect a ObjectDataSource to the ListView. You can use the SelectMethod for calling a function which is returning the data as (for example) a DataTable.

    StartRowIndexParameterName and MaximumRowsParameterName are parameters you need to be using in that function.

    You also need to tell the ObjectDataSource the total amount of items so the pagination know how many pages to use. This is done by selecting a function (which will return an integer) in SelectCountMehod.

    More info: https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource(v=vs.110).aspx