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

  • 相关阅读:
    Java 缩放图片工具类,创建缩略图、伸缩图片比例
    93、App Links (应用程序链接)实例
    92、App Permissions(权限管理)实例
    MAC系统教程网站
    Android MVP 详解
    Android开发中,那些让你相见恨晚的方法、类或接口
    用Ultra ISO制作启动U盘装系统
    DB2 Magazine 中文版: 访问 iSeries 数据
    Eclipse快捷键大全
    同步灵无线锂电鼠G11-580HX独特“五灵键”
  • 原文地址:https://www.cnblogs.com/footleg/p/1588156.html
Copyright © 2011-2022 走看看