在前台GRIDVIEW中添加如下代码

<PagerTemplate>

<table>

  <tr>

    <td style="text-align: right">

    第<asp:Label ID="lblPageIndex" runat="server" Text="<%#((GridView)Container.Parent.Parent).PageIndex + 1 %>"></asp:Label>页

    共<asp:Label ID="lblPageCount" runat="server" Text="<%# ((GridView)Container.Parent.Parent).PageCount %>"></asp:Label>页

    <asp:LinkButton ID="btnFirst" runat="server" CausesValidation="False" CommandArgument="First" CommandName="Page" Text="首页"> </asp:LinkButton>

    <asp:LinkButton ID="btnPrev" runat="server" CausesValidation="False" CommandArgument="Prev" CommandName="Page" Text="上一页"></asp:LinkButton>

    <asp:LinkButton ID="btnNext" runat="server" CausesValidation="False" CommandArgument="Next" CommandName="Page" Text="下一页"></asp:LinkButton>

    <asp:LinkButton ID="btnLast" runat="server" CausesValidation="False" CommandArgument="Last" CommandName="Page" Text="尾页"></asp:LinkButton>

    <asp:TextBox ID="txtNewPageIndex" runat="server" Text="<%# ((GridView)Container.Parent.Parent).PageIndex + 1%>" Width="20px"></asp:TextBox>

    <asp:LinkButton ID="btnGo" runat="server" CausesValidation="False" CommandArgument="-1" CommandName="Page" Text="GO"></asp:LinkButton>   

    </td>

  </tr>

</table>

</PagerTemplate>

后台代码添加如下代码

protected void PageIndexChanging(object sender, GridViewPageEventArgs e)

{

  GridView gvw = (GridView)sender;

  if (e.NewPageIndex < 0)

  {

    TextBox pageNum = (TextBox)gvw.BottomPagerRow.FindControl("txtNewPageIndex"); int Pa = int.Parse(pageNum.Text);

    if (Pa <= 0) { gvw.PageIndex = 0; }

    else { gvw.PageIndex = Pa - 1; }

  }

  else { gvw.PageIndex = e.NewPageIndex; }

  GetBind();//你绑定数据的方法

}

GridView自带分页 1总页数 首页 下一页 上一页 尾页 X 页 go 实现方法 .的更多相关文章

  1. 使用GridView自带分页的代码

    关于GridView分页页码的讨论 在GridView中实现分页的效果方法非常easy,仅仅须要在"GridView任务"对话框中进行设置就能够了.在"GridView任 ...

  2. GridView总结一:GridView自带分页及与DropDownList结合使用

    GridView自带的分页功能实现: 要实现GrdView分页的功能 操作如下: 1.更改GrdView控件的AllowPaging属性为true. 2.更改GrdView控件的PageSize属性为 ...

  3. mysql 数据库封装类:返回索引、关联、字符串数组;分页查询封装类 :$page=new Page(表的总条数,每页的条数);$sql = "".$page->limit; echo $page->fpage();

    <?php class czy { public $host="localhost"; //地址 public $uid="root"; //用户名 pu ...

  4. Yii2.0 多条件搜索 带分页

                                   方法一   在控制器中 ; if($titles!=""){ $where.=" and title lik ...

  5. 使用for或while循环来处理处理不确定页数的网页数据爬取

    本文转载自以下网站: Python For 和 While 循环爬取不确定页数的网页  https://www.makcyun.top/web_scraping_withpython16.html 需 ...

  6. dotnet获取PDF文件的页数

    #region 获取PDF文件的页数 private int BytesLastIndexOf(Byte[] buffer, int length, string Search) { if (buff ...

  7. C# 返回分页查询的总页数

    /// <summary> /// 返回分页查询操作的的总页数 /// </summary> /// <param name="count">总 ...

  8. easyui分页时,总页数出错

    错误出现 MyBatis用easyui写后台分页代码时,出现翻页后显示总页数错误 代码如下 可能原因在于后台mappers.xml里的sql语句错误 <select id="getPr ...

  9. mvc自定义分页(加页数的)(转)

    1.引言 在MVC开发中我们经常会对数据进行分页的展示.通过分页我们可以从服务端获取指定的数据来进行展示.这样既节约了数据库查询的时间也节约了网络传输的数据量.在MVC开发中使用的比较多的应该是MVC ...

随机推荐

  1. HDU 5584 LCM Walk 数学

    LCM Walk Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5584 ...

  2. 如何利用PhoneGap制作地图APP

    摘要:百度地图API是一套由javascript编写的地图程序接口,按说它应该运行在浏览器上.现在,只要利用PhoneGap,我们就能开发出移动平台上能使用的APP了! --------------- ...

  3. 区域医疗移动医疗影像解决方案1-基于HTML5的PACS

    系统描述: 1.系统基于HTML5开发,突破了平台限制,可以在任意移动终端的浏览器上调阅原始海量医学影像图像. 2.客户端无需任何下载安装,直接通过浏览器即可使用,并处理基于DICOM标准的高保真医学 ...

  4. defer属性---->执行外部脚本

    HTML4---->只有IE支持 不需要是外部脚本. HTML5---->主流都支持 defer 属性仅适用于外部脚本(只有在使用 src 属性时) 值 描述 defer 规定当页面已完成 ...

  5. 【Oracle】ORA-00600: [kfgFinalize_2]

    环境: OS:OEL5.6 RAC:10.2.0.1.0 [root@rac2 ~]# crs_stat -t Name           Type           Target    Stat ...

  6. install root certificate failed, Please run as administrator/root/sudo

    在钥匙窜中导入  证书就可以了

  7. 海量数据处理算法—Bit-Map

    原文:http://blog.csdn.net/hguisu/article/details/7880288 1. Bit Map算法简介 来自于<编程珠玑>.所谓的Bit-map就是用一 ...

  8. apt-mirror is already running(已运行)错误解决方案

    运行sudo apt-mirror却无法启动服务了.而是给出了一行错误提示信息:               apt-mirror is already running, exiting at /us ...

  9. Squish License

    https://www.froglogic.com/squish/gui-testing/prices-and-licensing/index.php Prices and Licensing Who ...

  10. storm 分组

    Stream Groupings: Stream Grouping定义了一个流在Bolt任务间该如何被切分.这里有Storm提供的6个Stream Grouping类型: 1. 随机分组(Shuffl ...