C# ASP.NET DataPager查看所有记录
听起来很简单-我有一个与datalist关联的datapager:C# ASP.NET DataPager查看所有记录,c#,asp.net,paging,web-controls,C#,Asp.net,Paging,Web Controls,听起来很简单-我有一个与datalist关联的datapager: <asp:DataPager runat="server" ID="uxPager" PageSize="10" PagedControlID="uxDataList" QueryStringField="page"> <Fields> <asp:NextPreviousPagerField FirstPageText="<<" Sho
<asp:DataPager runat="server" ID="uxPager" PageSize="10"
PagedControlID="uxDataList" QueryStringField="page">
<Fields>
<asp:NextPreviousPagerField FirstPageText="<<"
ShowFirstPageButton="True" ShowNextPageButton="False"
ShowPreviousPageButton="False" />
<asp:TemplatePagerField OnPagerCommand="PagerCommand">
<PagerTemplate>
Page
<asp:Label runat="server" ID="CurrentPageLabel"
Text="<%# Container.TotalRowCount>0 ?
(Container.StartRowIndex / Container.PageSize) + 1 : 0 %>" />
of
<asp:Label runat="server" ID="TotalPagesLabel"
Text="<%# Math.Ceiling (
(double)Container.TotalRowCount / Container.PageSize) %>" />
<asp:LinkButton ID="lbViewAll" runat="server" OnClick="ViewAll">
View All
</asp:LinkButton>
</PagerTemplate>
</asp:TemplatePagerField>
<asp:NextPreviousPagerField LastPageText=">>"
ShowLastPageButton="True" ShowNextPageButton="true"
ShowPreviousPageButton="True" PreviousPageText="Prev"
NextPageText="Next" />
</Fields>
当我逐步遍历它时,我的数据列表有95个项(这是我所期望的),但是数据列表呈现我的EmptyDataTemplate,即使我调用了DataBind()
如果有什么不同,我将使用XmlDataSource来驱动数据列表。受保护的void ViewAll(对象发送方,EventArgs e)这是由名为lbViewAll的按钮触发的吗?我有点困惑filldata实际上做了什么?换句话说,它真的能获取所有数据吗?
/// <summary>
/// Views all.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="System.EventArgs"/>
/// instance containing the event data.</param>
protected void ViewAll(object sender, EventArgs e)
{
uxServiceDirectoryPager.SetPageProperties(0,
uxServiceDirectoryPager.TotalRowCount,true);
}
uxServiceDirectoryPager.SetPageProperties(0, uxServiceDirectoryPager.TotalRowCount, true);
uxServiceDirectoryList.DataBind();