I'm having an issue where I have 2 DataPagers on the same page, linked to the same ListView. Everything works fine, except the "bottom" or 2nd pager doesn't seem to be working. The page numbers are generated, but clicking on them does nothing. If I copy the "bottom" pager above the "top" pager, then that pager will work, but the one below it doesn't. Seems a only the pager that comes first seems to work:
<asp:DataPager ID="dpPagerTop" runat="server" PagedControlID="lvOutput" QueryStringField="pageNumber">
<Fields>
<asp:NumericPagerField NextPageText="Next" PreviousPageText="Previous" />
</Fields>
</asp:DataPager>
<asp:DataPager ID="dpPagerBottom" runat="server" PagedControlID="lvOutput" QueryStringField="pageNumber">
<Fields>
<asp:NumericPagerField NextPageText="Next" PreviousPageText="Previous" />
</Fields>
</asp:DataPager>
<asp:ListView ID="lvOutput" runat="server" OnPagePropertiesChanged="lvOutput_PagePropertiesChanged">
<LayoutTemplate>
<asp:PlaceHolder id="itemPlaceholder" runat="server" />
</LayoutTemplate>
<ItemTemplate>
<a href="<%# Eval("Link") %>" title="<%# Eval("Title") %>"><%# Eval("Title") %></a>
</ItemTemplate>
</asp:ListView>
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
dpPagerTop.SetPageProperties(Request.QueryString["pageNumber"].ToString(), 25, false);
dpPagerBottom.SetPageProperties(Request.QueryString["pageNumber"].ToString(), 25, false);
lvOutput.DataSource = [datasource];
lvOutput.DataBind();
}
}
protected void lvOutput_PagePropertiesChanged(object sender, EventArgs e)
{
lvOutput.DataBind();
}
UPDATE:
After fooling around with this some more, I've determined that both pagers will work if SetPageProperties has the correct parameters. The first parameter should be the number to start the results and the second should be number of results to show. However, I am getting the wrong numbers to display. I have exactly 100 records and I want to display 25 results per page. If I hardcode:
dpPagerTop.SetPageProperties(25, 25, true);
dpPagerBottom.SetPageProperties(25, 25, true);
This should be the 2nd page of the results and the results show 26-50. However, the bottom pager doesn't work.
Now, if I hardcode:
dpPagerTop.SetPageProperties(26, 25, true);
dpPagerBottom.SetPageProperties(26, 25, true);
Both pagers work like the should, but the number of results go from 27-51.
Can anyone recreate this, it's driving me nuts?!?!?
UPDATE 2:
I think I got it to work by setting the page properties BEFORE binding to the ListView.