我正在尝试创建一个将使用 DataPager 控件的服务器控件,但我在使用 PagerTemplate 时遇到了一些困难。
这是我想从服务器控件生成的 DataPager 控件:
<asp:DataPager ID="myPager" PageSize="20" runat="server">
<Fields>
<asp:TemplatePagerField>
<PagerTemplate>
<div class="counter">
<%# Container.StartRowIndex + 1 %> to
<%# ((Container.StartRowIndex + Container.PageSize) > Container.TotalRowCount ? Container.TotalRowCount : (Container.StartRowIndex + Container.PageSize)) %>
of <%# Container.TotalRowCount %> records
</div>
</PagerTemplate>
</asp:TemplatePagerField>
<asp:NextPreviousPagerField ButtonType="link"
FirstPageText="first"
ShowFirstPageButton="true"
ShowNextPageButton="false"
ShowPreviousPageButton="false"
RenderDisabledButtonsAsLabels="true" />
<asp:NumericPagerField ButtonCount="7" />
<asp:NextPreviousPagerField ButtonType="link"
LastPageText="last"
ShowLastPageButton="true"
ShowNextPageButton="false"
ShowPreviousPageButton="false" />
</Fields>
</asp:DataPager>
我不知道如何从代码创建 PagerTemplate。我被困在需要创建 ITemplate 的部分,但我不知道如何使用它。
我做了一些搜索,但没有找到任何可以帮助我的东西。我是服务器控制的新手。我可以做一些简单的,但模板对我来说是新的。
谁能给我一些帮助?
谢谢 :)