在前台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. ajax跳转页面问题

    $.ajax({ type:"POST", url: //你的请求程序页面随便啦 async:false,//同步:意思是当有返回值以后才会进行后面的js程序. data://请求 ...

  2. cocos2d-x如何新建一个模板项目

    方法一: $ cd cocos2d-x$ ./setup.py$ source FILE_TO_SAVE_SYSTEM_VARIABLE$ cocos new MyGame -p com.your_c ...

  3. C# 如何编辑文件的摘要信息

    我的以前的测试报告程序需要在倒完测试数据报告后,在文件摘要中加上一些类似版权说明的文字等等. 因此需要对文件摘要信息进行编辑. 我的记忆中以前好像只有office文档才可以又摘要信息, 现在看来基本上 ...

  4. 视频流服务器配置[windows平台][转]

    视频流服务器配置[windows平台] 搭建一个Flv视频播放服务器 作者:笨小孩 发布于:2013-9-1 20:18 分类:环境架设 IIS,Apache,Nginx环境都可以很好的支持视频的播放 ...

  5. TP复习15

    ## ThinkPHP 3.1.2 URL#讲师:赵桐正微博:http://weibo.com/zhaotongzheng 本节课大纲:一.URL规则 1.默认是区分大小写的 2.如果我们不想区分大小 ...

  6. [AngularJS] Accessing Services from Console

    Using the Chrome console, you can access your AngularJS injectable services. This is down and dirty ...

  7. Linux 下配置网卡的别名即网卡子IP的配置 转

    what 什么是ip别名?用windows的话说,就是为一个网卡配置多个ip.when 什么场合增加ip别名能派上用场?布网需要.多ip访问测试.特定软件对多ip的需要...and so on. ho ...

  8. js获得控件位置

    网页可见区域宽:document.body.clientWidth 网页可见区域高:document.body.clientHeight 网页可见区域宽:document.body.offsetWid ...

  9. 去掉display:inline-block元素间的多余空白

    问题:每1个带display:inline-block;属性的链接 a 水平.垂直方向都带有一定的空白 关键在于父元素定义font-size:0 去掉行内块元素水平方向空白:子元素定义vertical ...

  10. linux连接静态库

    在项目中发现,使用 -l连接某个库时,如果存在同名的静态库(.a)和动态库(.so),默认会连接.so 那么如何指定连接静态库呢?如果有多个库,有些要连接静态库.有些要连接动态库,连接选项该如何指定呢 ...