您的位置:首页 > 其它

Gridview 绑定自定义页面模板

2010-09-17 09:01 387 查看
要在页脚显示如总页数的信息,你可以用<PagerTemplate>项,如下例所示:

<asp:GridView ID="GridView1" runat="server"

DataSourceID="SqlDataSource1"

DataKeyNames="ID"

AllowPaging="true"

PageSize="10"

AutoGenerateColumns="true">

<PagerTemplate>

<asp:Label ID="LabelCurrentPage" runat="server"

Text="<%# ((GridView)Container.NamingContainer).PageIndex + 1 %>">

</asp:Label>/

<asp:Label ID="LabelPageCount" runat="server"

Text="<%# ((GridView)Container.NamingContainer).PageCount %>">

</asp:Label>

<asp:LinkButton ID="LinkButtonFirstPage" runat="server"

CommandArgument="First"

CommandName="Page"

enabled="<%# ((GridView)Container.NamingContainer).PageIndex != 0

%>"><<

asp:LinkButton ID="LinkButtonPreviousPage" runat="server"

CommandArgument="Prev" CommandName="Page"

enabled="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>"><

</asp:LinkButton>

<asp:LinkButton ID="LinkButtonNextPage" runat="server"

CommandArgument="Next"

CommandName="Page"

enabled="<%# ((GridView)Container.NamingContainer).PageIndex !=

((GridView)Container.NamingContainer).PageCount - 1 %>">>

</asp:LinkButton>

<asp:LinkButton ID="LinkButtonLastPage" runat="server"

CommandArgument="Last"

CommandName="Page"

enabled="<%# ((GridView)Container.NamingContainer).PageIndex !=

((GridView)Container.NamingContainer).PageCount - 1 %>">>>

</asp:LinkButton>

</PagerTemplate>

</asp:GridView>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: