zoukankan      html  css  js  c++  java
  • Asp.net GridView分页

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                        CssClass="grid" AllowPaging="True" DataKeyNames="orderNO"  PageSize="5"
                        onpageindexchanged="GridView1_PageIndexChanged"
                        onpageindexchanging="GridView1_PageIndexChanging">
                        <Columns>
                            <asp:BoundField DataField="field1" HeaderText="名称" ReadOnly="True"  />
                            <asp:BoundField DataField="field2" HeaderText="名称"  />
                            <asp:BoundField DataField="field3" HeaderText="名称"  />
                            <asp:BoundField DataField="field4" HeaderText="名称"  />
                            <asp:BoundField DataField="field5" HeaderText="名称"  />
                        </Columns>
                        <PagerTemplate>
                            <br/>
                            <asp:Label ID="lblPage" runat="server" Text='<%# "第" + (((GridView)Container.NamingContainer).PageIndex + 1)  + "页/共" + (((GridView)Container.NamingContainer).PageCount) + "页" %> '></asp:Label>
                            <asp:LinkButton ID="lbnFirst" runat="Server" Text="首页"  Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>' CommandName="Page" CommandArgument="First" ></asp:LinkButton>
                            <asp:LinkButton ID="lbnPrev" runat="server" Text="上一页" Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>' CommandName="Page" CommandArgument="Prev"  ></asp:LinkButton>
                            <asp:LinkButton ID="lbnNext" runat="Server" Text="下一页" Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != (((GridView)Container.NamingContainer).PageCount - 1) %>' CommandName="Page" CommandArgument="Next" ></asp:LinkButton>
                            <asp:LinkButton ID="lbnLast" runat="Server" Text="尾页"   Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != (((GridView)Container.NamingContainer).PageCount - 1) %>' CommandName="Page" CommandArgument="Last" ></asp:LinkButton>
                            <br />
                        </PagerTemplate>
                    </asp:GridView>


    protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindRepeater(); 
            }
        }

        private void BindRepeater()
        {
            string userId = "1";
            DataTable dt = BankService.GetOrderListByUId(userId);
            this.GridView1.DataSource = dt;
            this.GridView1.DataBind();
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this.GridView1.PageIndex = e.NewPageIndex;
        }
        protected void GridView1_PageIndexChanged(object sender, EventArgs e)
        {
            BindRepeater();
        }

  • 相关阅读:
    springcloud之zuul
    rabbitmq工作模式(三)Topics通配符模式
    rabbitMQ工作模式(二)路由模式
    rabbitmq工作模式(一)发布订阅模式
    Eureka使用案例
    SpringCloud入门
    微服务
    F查询和Q查询,摘自李文周老师
    django08 orm之增删改查
    django07 字符串替换
  • 原文地址:https://www.cnblogs.com/aweifly/p/2741592.html
Copyright © 2011-2022 走看看