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

  • 相关阅读:
    如何彻底卸载Oracle11g
    Oracle 11g的安装
    python 循环队列的实现
    numpy模块学习笔记
    Python 进程之间共享数据
    python异步加协程获取比特币市场信息
    MySQL中, 如何查询某一天, 某一月, 某一年的数据.
    js获取时间
    nodejs爬虫笔记(五)---利用nightmare模拟点击下一页
    nodejs爬虫笔记(四)---利用nightmare解决加载更多问题
  • 原文地址:https://www.cnblogs.com/footleg/p/1588156.html
Copyright © 2020-2023  润新知