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

  • 相关阅读:
    2017年计划安排
    Angular企业级开发(4)-ngResource和REST介绍
    Angular企业级开发(3)-Angular MVC实现
    Angular企业级开发(2)-搭建Angular开发环境
    Angular企业级开发(1)-AngularJS简介
    复习下C 链表操作(双向链表)
    复习下C 链表操作(单向循环链表、查找循环节点)
    复习下C 链表操作(单向链表)
    隐藏状态栏
    关于CALayer 中的contents(图片) 拉伸
  • 原文地址:https://www.cnblogs.com/footleg/p/1588156.html
Copyright © 2011-2022 走看看