Search code examples
asp.netrepeatercustompaging

accessing paged data source from itemDataBound in asp.net


I've bound my repeater to a PagedDataSource and I want to get the PagedCount from the ItemDataBound event. I've tried a few things and it's not working. Does anyone know how to do this?


Solution

  • It's probably been resolved, but here goes.

    You want to use this value when binding the footer element for paging, right? You can access the datasource on databound.

    List<object> dataSource = repeater.DataSource as List<object>;
    

    The DataSource will be null, though, after all the items have been bound.

    When binding the buttons or links, you can set the page numbers in button.CommandArgument and set button.CommandName = "next", for example. Then ofcourse add the OnItemCommand stuff.