Set PageIndex of DataPager

一曲冷凌霜 提交于 2019-12-13 14:26:34

问题


I have a ListView that I am paging with a DataPager. I would like to set the initial page of the pager on Page_Load. I have tried the DataPager.SetPageProperties method but it's not doing what I need. Here's how I'm calling this method:

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

The line above trims the datasource to start at the third item and paging still starts at 1. This is not what I want. I want to keep the entire list of items and just jump to a specific page in the list.

Is there another Property and/or method of a DataPager and/or ListView that I should use?

Any help will be greatly appreciated.

Thanks!


回答1:


Try this. Not tested.

--edited--

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



回答2:


If you're binding your datasource by code,you can manually set PageIndex in 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's up to you actually.
grd.DataBind();

The point is before databinding you have to set new page index.
Best Regards
Myra



来源:https://stackoverflow.com/questions/2698954/set-pageindex-of-datapager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!