Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have this datapager and I want to get the current page. I checked out the properties of about everything and the MSDN documentation and I still did not find anything useful to get the current page. Can anyone help?

<asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1" PageSize="10">

<Fields>

<asp:NextPreviousPagerField ButtonType="Link" FirstPageText="<<" PreviousPageText="<" ShowFirstPageButton="true" ShowNextPageButton="false" />

<asp:NumericPagerField ButtonCount="3" />

<asp:NextPreviousPagerField ButtonType="Link" LastPageText=">>" NextPageText=">" ShowLastPageButton="true" ShowPreviousPageButton="false" />

</Fields>

</asp:DataPager>
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

This isn't a SharePoint question, however here is the answer:

That data isn't actual stored as part of the Data Pager control. It is done with the ListView or GridView. (See http://www.4guysfromrolla.com/articles/021308-1.aspx for some more information on that).

Basically you can use the StartRowIndex property of the ListView/GridView to determine where you are. You may want to tweak the math a bit for your needs, but if you divide the StartRowIndex by the page size and then either round up to one, if less than one, or round down to the nearest whole number, you should end up with the page you are on.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.