DateGradeView分页绑定
<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分页绑定的更多相关文章
- ASP.NET 动态属性筛选和分页绑定
分页控件为:AspNetPager.dll 我们先建立一个产品属性名称表 CREATE TABLE ProductAttr ( ,) NOT NULL primary key, [ParentID] ...
- linq中分组查询而且获取每个分组中的第一条记录,数据用于分页绑定
LINQ分组取出第一条数据 Person1: Id=1, Name="Test1" Person2: Id=1, Name="Test1" Person3: I ...
- template-web.js 真分页绑定表格
<div class="layui-table-box"> <div class="layui-tabl ...
- Jquery制作可以绑定的表格
//总页数 当前页 可见页 参数 翻页执行后处理的函数 function PageTable(totalPages, currentPage, tableobj, url, where, column ...
- c# 高效分页只需一个dll实例
第一.首先下载WebUIControl.dll http://pan.baidu.com/s/1gdkilDh 第二.添加引用 三.应用实例-前台代码 <%@ Register Assembly ...
- c#一个分页控件的例子
一.首先下载一个dll,地址:http://pan.baidu.com/share/link?shareid=1628211605&uk=1342867987 二.添加到项目中 三.添加引用 ...
- 【转载】Lucene.Net无障碍学习和使用:搜索篇
在上一篇中,我们初步理解了索引的增删改查基本操作.本文着重介绍一下常用的搜索,以及搜索结果的排序和分页.本文的搜索主要是基于前一篇介绍的文本文件的索引,建议下载最后改进的demo对照着看阅读本文,同时 ...
- updatePanel导致JS失效的解决办法(转)
吐槽下,维护别人之前做的项目好蛋疼,整个页面都是用微软的ajax框架. 今天给repeater用JS写一个hover事件 <script type="text/javascript&q ...
- asp.net将sql语句封装在类库中
将sql语句封装在cs中,通过类库的引用使用他的select.update.insert 源代码(cs): using System; using System.Collections.Generic ...
随机推荐
- 关于xml作为模板的配置服务系统开发
最近在做一个后台配置系统,其实之前也接触过,所谓的配置系统就是指,将你的网站布局抽象成一个xml模板,里面包括你自定义的节点,然后将变化的部分作为配置项,通过服务将配置选项与模板组装成一个js(这个服 ...
- C# 自定义线程修改UI(一)
在Wpf中界面显示数据的修改,都是通过UI线程完成,如果尝试从其他线程中直接修改控件的值回抛出异常,“调用线程无法访问此对象,因为另一个线程拥有该对象”. 例如:http://www.cnblogs. ...
- c#将Excel数据导入到数据库的实现代码(OleDb)
sing System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web ...
- [个人原创]关于java中对象排序的一些探讨(二)
2. 使用Collections.sort()方法 Collections类中提供了诸多静态方法,诸如addAll(),max()等等.当自己相对Collection接口下的类处理的时候,可以看看这 ...
- POJ2566-Bound Found (尺取法)
POJ2566-Bound Found 题目大意:给出一段长度为n的数列,数列中的元素有正有负,求一段连续的区间,使得该区间的和的绝对值最接近给定的值 尺取法一般适用于对一段连续的区间的和进行处理的情 ...
- jquery图片轮播代码
自己写的轮播代码 来张样式效果图 先贴HTML样式 <body> <div id = "wrap"> <div id="lunbo-img& ...
- uva 580 危险的组合(排列组合)
Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu Submit Status Descript ...
- CodeForces 474B(标记用法)
CodeForces 474B Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Descript ...
- Egret 矢量绘图、遮罩、碰撞检测
矢量绘图: 1. 为矢量绘图绘制外边 - graphics.lineStype() private createGameScene():void { console.log("Runtime ...
- Java中堆内存(heap)和栈内存(stack)的区别
在Java代码中,常常会使用到这样的类的声明实例化: Person per = new Person(); //这其实是包含了两个步骤,声明和实例化 Person per = null; //声明一个 ...