Install PageIndex of DataPager

I have a ListView that I view using a DataPager. I would like to set the initial pager page to page_Load. I tried the DataPager.SetPageProperties method, but it doesn't do what I need. This is how I call this method:

dataPager.SetPageProperties(3, dataPager.TotalRowCount, false);

      

The line above truncates the data source to start at the third item, and the paging still starts at 1. This is not what I want. I want to keep the entire list of items and just navigate to a specific page in the list.

Is there any other DataPager and / or ListView property and / or method that I should be using?

Any help would be greatly appreciated.

Thanks!

+2


a source to share


2 answers


Try it. Not tested.

- edit -



dataPager.SetPageProperties( 
    (3 * dataPager.PageSize, 
    dataPager.MaximumRows, 
    false
);

      

+5


a source


If you are binding your datasource by code, you can manually set the PageIndex parameter in the binding method.

grd.DataSource = something ..
grd.PageIndex = initialIndex;//where initialIndex is the index you wish to set
//you can arrange this index in your code,it up to you actually.
grd.DataBind();

      



Before you bind data, you need to set a new page index.

Best wishes
Myra

0


a source







All Articles