c# - How to set the page number at runtime in datapager -
i've created links in listview attached datapager. when user clicks link see content left datapager changes page page 1.
you need add querystring field indicating page number each of links. need set querystringfield attribute of datapager control equal name of querystring field.
for example:
<asp:datapager id="dpitems" runat="server" pagedcontrolid="lvitems" pagesize="10" querystringfield="pagenumber">
from msdn: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datapager.querystringfield.aspx
if want paging math yourself, can set startrowindex property @ runtime. can't, however, set page directly. eg., if displaying 10 records per page, , want display second page, set mydatapager.startrowindex = 20 in runtime code.
alternatively, datapager can handle math automatically , generate paging controls when set datapager's fields , set querystringfield value. can either have use next/previous buttons, numeric page links, or define own paging controls in template.
if defining own paging controls, this:
then in lvitems's ondatabound event, grab placeholder (placeholder)lvitems.findcontrol("phpagenumberbuttons") , add controls placeholder.
also, make sure define pagedcontrolid equal listview's id
here's link msdn article can more information on fields: msdn.microsoft.com/en-us/library/
Comments
Post a Comment