zoukankan      html  css  js  c++  java
  • GridView自身分页加跳转

    <PagerTemplate>
    <asp:LinkButton ID="lbFirst" runat="server" CausesValidation="False" CommandArgument="First"
    CommandName="Page">首页 </asp:LinkButton>
    <asp:LinkButton ID="lbPrev" runat="server" CausesValidation="False" CommandArgument="Prev"
    CommandName="Page">上一页 </asp:LinkButton>
    <asp:LinkButton ID="lbNext" runat="server" CausesValidation="False" CommandArgument="Next"
    CommandName="Page">下一页 </asp:LinkButton>
    <asp:LinkButton ID="lbLast" runat="server" CausesValidation="False" CommandArgument="Last"
    CommandName="Page">尾页 </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="-1"
    CommandName="Page" Text="GO"> </asp:LinkButton>
    </PagerTemplate>
    CS代码:

    //添加对lbGO单击事件
        protected void GoIndex(object sender, EventArgs e)
        {
            GridViewRow pagerRow = GridView1.BottomPagerRow;
            TextBox pageNum = pagerRow.Cells[0].FindControl("tbpage") as TextBox;
            if (pageNum.Text != null)
            {
                if (Convert.ToInt32(pageNum.Text) > 0 && Convert.ToInt32(pageNum.Text) <= GridView1.PageCount)
                GridView1.PageIndex = Convert.ToInt32(pageNum.Text) - 1;
            }
            this.BindToGridView();
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            if (e.NewPageIndex >= 0 && e.NewPageIndex < GridView1.PageCount)
            this.GridView1.PageIndex = e.NewPageIndex;
            this.BindToGridView();   //调用上面的BindToGridView()绑定
        }

  • 相关阅读:
    MySQL数据库高并发优化配置
    MySQL性能参数详解
    jQuery中过滤选择器first和first-child的区别
    Linux非常用命令
    jps命令学习
    通过乐观锁(版本号)降低并发时的锁竞争
    ReentrantLock 相关学习笔记
    grep 所有多个关键字
    ThreadLocal学习笔记
    Idea设置全白色 背景
  • 原文地址:https://www.cnblogs.com/footleg/p/1588156.html
Copyright © 2011-2022 走看看