zoukankan      html  css  js  c++  java
  • GridView 手写分页 初级

    今天研究这个研究了半天,初步了解了GridView自动分页是如何操作的 话不多 贴代码、

     <PagerTemplate>
                        <asp:LinkButton ID="lbFirst" runat="server" CausesValidation="False" CommandArgument="First"
                            CommandName="Page">First</asp:LinkButton>
                        <asp:LinkButton ID="lbPrev" runat="server" CausesValidation="False" CommandArgument="Prev"
                            CommandName="Page">Prev</asp:LinkButton>
                        <asp:LinkButton ID="lbNext" runat="server" CausesValidation="False" CommandArgument="Next"
                            CommandName="Page">Next</asp:LinkButton>
                        <asp:LinkButton ID="lbLast" runat="server" CausesValidation="False" CommandArgument="Last"
                            CommandName="Page">Last</asp:LinkButton>
                        第<asp:Label ID="Label2" runat="server" Text="<%#((GridView)Container.Parent.Parent).PageIndex + 1 %>"></asp:Label>页
                        共<asp:Label ID="Label1" runat="server" Text="<%# ((GridView)Container.Parent.Parent).PageCount %>"></asp:Label>页
                        跳到<asp:TextBox ID="tbPage" runat="server" Text="<%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>"
                            Width="27px"></asp:TextBox>
                        <asp:LinkButton ID="lbGO" runat="server" CausesValidation="False" CommandArgument="0"
                            CommandName="Page" Text="GO"></asp:LinkButton>
     </PagerTemplate>

    //添加PageIndexChanging事件  注意:这个是必须的

     protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView gvw = (GridView)sender;
            if (e.NewPageIndex < 0)
            {
                TextBox pageNum = (TextBox)gvw.BottomPagerRow.FindControl("tbPage");
                int Pa = int.Parse(pageNum.Text);
                if (Pa <= 0)
                    gvw.PageIndex = 0;
                else
                    gvw.PageIndex = Pa - 1;
            }
            else
            {
                gvw.PageIndex = e.NewPageIndex;
            }
            GridView_Bind();
        }

    <%#((GridView)Container.Parent.Parent).PageIndex + 1 %>  显示当前页

  • 相关阅读:
    hdu 2544 单源最短路问题 dijkstra+堆优化模板
    CImg、libjpeg--介绍、配置(操作JPEG)
    【Android归纳】开发中应该注意的事项
    iOS測试——置换測试: Mock, Stub 和其它
    <html>
    系统吞吐量、TPS(QPS)、用户并发量、性能測试概念和公式
    hdu 1038 Biker&#39;s Trip Odometer(水题)
    java泛型
    从头认识Spring-2.1 自己主动装配(2)-byType(2)
    11.2.0.3 RAC(VCS)节点crash以及hang的问题分析
  • 原文地址:https://www.cnblogs.com/Kiros/p/1886871.html
Copyright © 2011-2022 走看看