Gridview分页模板

通过<PagerTemplate>……</PagerTemplate>来实现分页。代码如下:
<PagerTemplate>
          <div id="pageindex" align="right">
            第<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"
             Visible="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>">返回首页</asp:LinkButton>

            <asp:LinkButton ID="LinkButtonPreviousPage" runat="server" CommandArgument="Prev" CommandName="Page"
             Visible="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>">上一页</asp:LinkButton>

            <asp:LinkButton ID="LinkButtonNextPage" runat="server" CommandArgument="Next" CommandName="Page"
             Visible="<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>">下一页</asp:LinkButton>

            <asp:LinkButton ID="LinkButtonLastPage" runat="server" CommandArgument="Last" CommandName="Page"
             Visible="<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>">最后一页</asp:LinkButton>
          </div>
        </PagerTemplate>

posted @ 2009-09-04 10:55  kerry1986  阅读(932)  评论(0编辑  收藏  举报