<form method="post" id="nform" runat="server">
               <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowPaging="True" DataKeyNames="CollageID"
                    Width="90%" OnPageIndexChanging="GridView1_PageIndexChanging" OnRowCreated="GridView1_RowCreated"
                   CellPadding="4" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" BackColor="White"
                   BorderColor="#3366CC"  BorderStyle="None" BorderWidth="1px"  >               
                <Columns>
                    <asp:BoundField DataField="CollageName" HeaderText="学院名称" />
                    <asp:BoundField DataField="Explain" HeaderText="学院简介" />
                    <asp:BoundField DataField ="CreateTime" HeaderText="创建时间"/>   
                    <asp:HyperLinkField DataNavigateUrlFields="CollageName" DataNavigateUrlFormatString="CollageTableDetail.aspx?id={0}" Text="查看详情" HeaderText="详细信息" />
                    <asp:HyperLinkField DataNavigateUrlFields="CollageID" DataNavigateUrlFormatString="CallbackURl.aspx?id={0}" HeaderText="操作" Text="删除" />
                </Columns>
                   <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
                   <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
                   <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Center" />
                <PagerTemplate>
                    <asp:LinkButton ID="cmdFirstPage" runat="server" CommandName="Page" CommandArgument="First" Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=0 %>" CausesValidation="False">首页</asp:LinkButton>
                    <asp:LinkButton ID="cmdPreview" runat="server" CommandArgument="Prev" CommandName="Page" Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=0 %>" CausesValidation="False">上一页</asp:LinkButton>
                    <asp:PlaceHolder runat="server" ID="Numeric" />
                    <asp:LinkButton ID="cmdNext" runat="server" CommandName="Page" CommandArgument="Next" Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=((GridView)Container.Parent.Parent).PageCount-1 %>" CausesValidation="False">下一页</asp:LinkButton>
                    <asp:LinkButton ID="cmdLastPage" runat="server" CommandArgument="Last" CommandName="Page" Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=((GridView)Container.Parent.Parent).PageCount-1 %>" CausesValidation="False">末页</asp:LinkButton>
                </PagerTemplate>
                   <RowStyle BackColor="White" ForeColor="#003399" />
                   <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
                   <SortedAscendingCellStyle BackColor="#EDF6F6" />
                   <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
                   <SortedDescendingCellStyle BackColor="#D6DFDF" />
                   <SortedDescendingHeaderStyle BackColor="#002876" />
            </asp:GridView>
           </form>        
  </div>

<!--后台代码-->

protected IList<CollageTable> list = new List<CollageTable>();         MesaageBal bal = new MesaageBal();         protected void Page_Load(object sender, EventArgs e)         {             Bind();         }         public void Bind()         {             list = bal.selectcollage();             GridView1.DataSource = list;             GridView1.DataBind();         }         protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)         {             GridView1.PageIndex = e.NewPageIndex;             GridView1.DataBind();

}

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)         {             if (e.Row.RowType == DataControlRowType.Pager)             {                 PlaceHolder ph = e.Row.FindControl("Numeric") as PlaceHolder;                 for (int i = 1; i <= GridView1.PageCount; i++)                 {                     var btn = new LinkButton { CommandName = "Page", CommandArgument = i.ToString(), Text = "[" + i + "]" };                     ph.Controls.Add(i - 1 != GridView1.PageIndex ? (Control)btn : new LiteralControl(i.ToString()));                     ph.Controls.Add(new LiteralControl(" "));                 }             }         }         protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)         {             int indexs = GridView1.SelectedIndex;            Response.Write(indexs+"");         }

DateGradeView分页绑定的更多相关文章

  1. ASP.NET 动态属性筛选和分页绑定

    分页控件为:AspNetPager.dll 我们先建立一个产品属性名称表 CREATE TABLE ProductAttr ( ,) NOT NULL primary key, [ParentID] ...

  2. linq中分组查询而且获取每个分组中的第一条记录,数据用于分页绑定

    LINQ分组取出第一条数据 Person1: Id=1, Name="Test1" Person2: Id=1, Name="Test1" Person3: I ...

  3. template-web.js 真分页绑定表格

     <div class="layui-table-box">                        <div class="layui-tabl ...

  4. Jquery制作可以绑定的表格

    //总页数 当前页 可见页 参数 翻页执行后处理的函数 function PageTable(totalPages, currentPage, tableobj, url, where, column ...

  5. c# 高效分页只需一个dll实例

    第一.首先下载WebUIControl.dll http://pan.baidu.com/s/1gdkilDh 第二.添加引用 三.应用实例-前台代码 <%@ Register Assembly ...

  6. c#一个分页控件的例子

    一.首先下载一个dll,地址:http://pan.baidu.com/share/link?shareid=1628211605&uk=1342867987 二.添加到项目中 三.添加引用 ...

  7. 【转载】Lucene.Net无障碍学习和使用:搜索篇

    在上一篇中,我们初步理解了索引的增删改查基本操作.本文着重介绍一下常用的搜索,以及搜索结果的排序和分页.本文的搜索主要是基于前一篇介绍的文本文件的索引,建议下载最后改进的demo对照着看阅读本文,同时 ...

  8. updatePanel导致JS失效的解决办法(转)

    吐槽下,维护别人之前做的项目好蛋疼,整个页面都是用微软的ajax框架. 今天给repeater用JS写一个hover事件 <script type="text/javascript&q ...

  9. asp.net将sql语句封装在类库中

    将sql语句封装在cs中,通过类库的引用使用他的select.update.insert 源代码(cs): using System; using System.Collections.Generic ...

随机推荐

  1. python文档字符串

    #coding=utf-8 #文档字符串def d(i,j): """这个函数实现了一个乘法运算. 函数会返回一个乘法运算的结果.""" k ...

  2. ASP.NET-FineUI开发实践-12

    1.网上找到了行合并的示例,extjs写的,我把它挪过来改了下,FineUI也能用,就是只能放着看,选择和编辑行扩展列没有测试,放出来大家看着用吧. <script> F.ready(fu ...

  3. 13、SQL Server 自定义函数

    SQL Server 自定义函数 在SQL Server中不仅可以使用系统函数(如:聚合函数,字符串函数,时间日期函数等)还可以根据需要自定义函数. 自定义函数分为标量值函数和表值函数. 其中,标量值 ...

  4. cocopods安装

    CocoaPods安装和使用教程 Code4App 原创文章.转载请注明出处:http://code4app.com/article/cocoapods-install-usage 目录 CocoaP ...

  5. 8个不可不知的Mac OS X专用命令行工具(转)

    OS X的终端下通用很多Unix的工具和脚本.如果从Linux迁移到OS X会发现很多熟悉的命令和脚本工具,其实并没有任何区别. 但是OS X也提供了很多其他系统所没有的特别的命令行工具.我们推荐8个 ...

  6. Windows Phone获得IsolatedStorage中指定目录下的所有文件

    在Windows Phone 中对隔离存储空间中的文件操作需要通过System.Io.IsolatedStorage下的类进行操作 获得指定文件夹下的所有文件: 参数:是指定文件夹的路径加上通配符,格 ...

  7. 『重构--改善既有代码的设计』读书笔记----Replace Method with Method Object

    有时候,当你遇到一个大型函数,里面的临时变量和参数多的让你觉得根本无法进行Extract Method.重构中也大力的推荐短小函数的好处,它所带来的解释性,复用性让你收益无穷.但如果你遇到上种情况,你 ...

  8. PHP mysql 删除表中所有数据只保留一条

    DELETE FROM `logs` WHERE wangzhi='www.juhutang.com' and id<>101072; 上面这段代码的意思为 删除表logs中 所有字段wa ...

  9. sql如何向一个表中批量插入大量数据

    --如果是一个表插入另外一个表.insert into tb1 需要的列名 select 按照前面写上需要的列名 from tb2 --如果两表结构一样.insert into tb1 * selec ...

  10. JQuery Dialog(JS模态窗口,可拖拽的DIV) 效果实现代码

    效果图 调用示意图   交互示意图 如上图所示,这基本是JQueryDialog的完整逻辑流程了. 1.用户点击模态窗口的“提交”按钮时,调用JQueryDialog.Ok()函数,这个函数对应了用户 ...