【问题标题】:how to have both page numbers and and next & previous buttons in custom pager in asp.net grid view?如何在asp.net网格视图的自定义寻呼机中同时拥有页码和下一个和上一个按钮?
【发布时间】:2011-08-14 21:33:26
【问题描述】:

我想要的是这种类型的分页结构。

我可以使用下面的代码显示上一个和下一个按钮,它们也很实用。

    <PagerTemplate>

          <asp:LinkButton CommandName="Page" CommandArgument="Prev" ID="LinkButton2" runat="server" Style="color: Black">
                <asp:Image ID="Image2" runat="server" ImageUrl="~/Images/videos_page_arrow_previous.gif"/>
          </asp:LinkButton>

          [Records <%= gridviewVideos.PageIndex * gridviewVideos.PageSize%>-<%= gridviewVideos.PageIndex * gridviewVideos.PageSize + gridviewVideos.PageSize - 1%>]

          <asp:LinkButton CommandName="Page" CommandArgument="Next" ID="LinkButton3" runat="server" Style="color: Black">
                <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/videos_page_arrow_next.gif"/>
          </asp:LinkButton>  

    </PagerTemplate>

但我不确定如何在它们之间获取页码。我的每页包含 5 行,如果我使用中继器控件来执行此操作,那么如何?

【问题讨论】:

    标签: c# asp.net gridview pagination


    【解决方案1】:

    对于这些场景,您最好使用asp:ListViewasp:DataPager。但是,如果您坚持使用 asp:GridView,则应将其扩展为使用 asp:DataPager

    我一直在使用 Matt Berseth 的 Using a DataPager with the GridView Control - Implementing IPageableItemContainer。但是演示/下载站点已关闭。所以你可以从GridView with DataPager in ASP.NET 3.5 下载相同的代码,我相信它或多或少是相同的代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-08
      • 2014-10-13
      • 2013-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多