<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. PHP微信公众号 access_token缓存

    PHP创建access_token.json文件,将access_token 和 生成时间expires 保存在其中, {"access_token":"xxxx&quo ...

  2. CSS3 @font-face使用实例

    Windows10操作系统使用实例: 1.准备好对应格式的字体库 2.方正字体使用实例 <!DOCTYPE html> <html> <head> <meta ...

  3. (转)织梦dedecms模板。如何让type='image'和不带type='image'的文章同时出现在列表里。

    “节日歌圩”栏目是有内容的,但是文章没有缩略图所以没有在频道首页显示出来,我现在想要有缩略图的文章自然显示,没有缩略图的文章也能出现标题列表(依然按照一行4个标题,可以用一张“无缩略图”的图片来代替缩 ...

  4. (转)echo和print的区别

    在实际使用中, print 和 echo 两者的功能几乎是完全一样.可以这么说,凡是有一个可以使用的地方,另一个也可以使用.但是,两者之间也还是一个非常重要的区别:在 echo 函数中,可以同时输出多 ...

  5. 第一个shell编程,输出hello world!

    在计算机科学中,Shell俗称壳(用来区别于核),是指“提供使用者使用界面”的软件(命令解析器).它类似于DOS下的command和后来的cmd.exe.它接收用户命令,然后调用相应的应用程序.--- ...

  6. iscroll.js & flipsnap.js

    两个js都可以用做手机的滑动框架iscroll.js功能更多flipsnap.js应该只能水平滑动. iscroll.js介绍http://iiunknown.gitbooks.io/iscroll- ...

  7. 完全用 GNU/Linux 工作(转)

    转自:http://www.chinaunix.net/old_jh/4/16102.html 看到一半,实在太长,但已觉得很好,转来分享一下. 完全用 GNU/Linux 工作 - 摈弃 Windo ...

  8. 支持mdev的init脚本片断

    mount -t tmpfs mdev /dev mount -t sysfs sysfs /sys mkdir /dev/pts mount -t devpts devpts /dev/pts ec ...

  9. (转载)图解Linux系统的系统架构

    我以下图为基础,说明Linux的架构(architecture).(该图参考<Advanced Programming in Unix Environment>) 最内层是硬件,最外层是用 ...

  10. WPS 去掉自动打开的文档漫游和在线模板

    关闭文档漫游  在cmd(命令提示符)中输入regedit.exe回车,将弹出”注册表编辑器“,选择HKEY_CURRENT_USER>>Software>>Kingsoft& ...