2010-08-03 94 views
0

我有一个奇怪的问题,我不明白DataPager。在改变页面集合(例如第6-10页)并点击页面(6,7,8,9或10)之后,它将再次显示从1开始计数的第一组页面。DataPager跳回第一页

让我解释一下。我有一个Listview和DataPager ASP.Net页面。

<asp:ListView ... DataSourceId="EntityDataSource" DataKeyNames="id"> 
    <LayoutTemplate> 
     <asp:DataPager runat="server" ID="DataPager1" PageSize="15"> 
      <Fields> 
       <asp:NextPreviousPagerField FirstPageText="&lt;&lt;" ShowFirstPageButton="True" ShowNextPageButton="False" 
         ShowPreviousPageButton="False" /> 
       <asp:NumericPageField /> 
       <asp:NextPreviousPagerField LastPageText="&gt;&gt;" ShowLastPageButton="True" ShowNextPageButton="False" 
         ShowPreviousPageButton="False" /> 
      </Fields> 
     </asp:DataPager> 
    </LayoutTemplate> 
</asp:ListView> 

要更新数据,我在PreRender期间做了一个DataBind。

protected override void OnPreRender(EventArgs e) 
{ 
     lstview1.DataBind(); 
     base.OnPreRender(e); 
} 

所有这些工作,但问题是,在回发期间的一组页面不会记住。让我解释一下。

通过页面的第一次请求时,页面显示:

< < 1 2 3 4 5 ... >>

通过单击...,将显示下一组网页(而且6页的数据将显示)

< < ... 6 7 8 9 10 ... >>

但是,当我第7页上单击以10页的文本将显示第一组1-5页。

有人可以解释为什么会发生这种情况吗?想我什么?谢谢。

回答