You need to use a pageable data source. The simplest way is to just use an SqlDataSource
.
Also, note that PageIndex
is zero-based.
If you're using a List
or a Collection
etc., it needs to be big enough, which is a nice waste of space. Basically, if you're doing manual paging, and you're using a List
, you're going to have to create the List
as big as the full record count of your result, and only fill in the proper page. Not very practical, and quite wasty, but it's simple enough.
Apart from creating your own pageable data source, there's also another, nicer way. You can use the AllowCustomPaging
property to specify that you're already passing paged data. Just set VirtualItemCount
to the record count, and pass just the one page in the DataSource
and call DataBind
as usual. That should do :)