ObjectContainerDataSource and Dynamic PagerSize

Feb 5, 2009 at 11:11 PM

Is there an example to use ObjectContinaerDataSource custom paging with changing PagerSize dynamically?

i.e. Use can select from a dropdown box on the page to choose how many recordes to diaplay on each page.

I tried to put a dropdown box on the custom paging quickstart example. However, if you are on a page greater than page 1 under smaller pagesize, after selecting a bigger pager size it will not return any records.

e.g. when there are only two records in the datasource, select page 2 under pager size 1 first, after changing to pager size 2, the gridview display nothing.

Feb 10, 2009 at 12:10 PM


When you select a new value in the DropDownBox that you added to the QuickStart, Are you changing only the value of the ObjectContainerDataSource’s TotalRowCount property or also the GridView’s PageSize property?

When you perform paging, it is a common practice check after you change the page size if the actual page exists in the new pages range. In case that the actual page is outside the valid range, you should set the actual page to last valid one. You can check this behavior in a lot of web sites, for example in the Codeplex’s discussion forums.


For example, you can use the PageCount property of the GridView control to see how many pages you need to show all the information and compare with the PageIndex property to ensure that the actual page is inside the valid range.


Please, let me know if this helps or else provide more information or code about your implementation, so I can continue helping to find the cause of this behavior.


Ezequiel Sculli


Feb 10, 2009 at 1:53 PM
Thanks, that is very helpful.