• 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();
        }

  • 相关阅读:
    JAVA Shallow heap & Retained heap
    JAVA-堆区,栈区,方法区。
    Android经典的设计模式
    Android 绘制view的小知识点
    Android View的滑动 动画
    Android开发aidl使用中linkToDeath和unlinkToDeath的使用
    Android任务栈的运行规律
    Android 通过httppost上传文本文件到服务器。
    Android中的Libraries以及Order and Export的使用。
    drawable微技巧以及layout的小知识
  • 原文地址:https://www.cnblogs.com/aweifly/p/2741592.html
Copyright © 2020-2023  润新知