Take the following example...a page with a ListView
and a DataPager
used for paging the data of the ListView
:
Code Behind:
protected void Page_Load(object sender, EventArgs e)
{
MyList.DataSource = GetSomeList();
MyList.DataBind();
}
Source:
<asp:ListView ID="MyList" runat="server">
<% //LayoutTemplate and ItemTemplate removed for the example %>
</asp:ListView>
<asp:DataPager ID="ListPager" PagedControlID="MyList" runat="server" PageSize="10">
<Fields>
<asp:NumericPagerField />
</Fields>
</asp:DataPager>
The problem with the DataPager
is that it is always a step-behind with the binding.
For example, when the page loads it's on page number 1. Then when you click on page 3, it stays on page 1 after the postback. Then you click on page 5, and after the postback it finds itself on page 3...and after that you click on page 6, and it finds itself on page 5...and so on and so forth.
Why isn't the paging working as expected?