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 ...
随机推荐
- 关于图表的JS插件
http://echarts.baidu.com/ http://echarts.baidu.com/tutorial.html#5%20%E5%88%86%E9%92%9F%E4%B8%8A%E6% ...
- 关于php优化的方法
1. 如果能将类的方法定义成static,就尽量定义成static,它的速度会提升将近4倍.2.$row[’id’] 的速度是$row[id]的7倍.3.echo 比 print快,并且使用echo的 ...
- 转:常用的HTML标签和属性解释
基本结构标签: <HTML>,表示该文件为HTML文件 <HEAD>,包含文件的标题,使用的脚本,样式定义等 <TITLE>---</TITLE>,包含 ...
- Java基础--说集合框架
版权所有,转载注明出处. 1,Java中,集合是什么?为什么会出现? 根据数学的定义,集合是一个元素或多个元素的构成,即集合一个装有元素的容器. Java中已经有数组这一装有元素的容器,为什么还要新建 ...
- MTP设备无法安装驱动的解决办法
1,进入设备管理器右击带黄色问号的MTP,选择“属性”,“详细信息”“设备范例 ID”(用Ctrl+C复制). 2,找到c:\windows\inf\wpdmtp.inf打开(或者通过运行打开),找到 ...
- 两个示例介绍JavaScript的闭包
JavaScript的闭包有两个用途:一个是访问函数内部的变量:另一个是让变量的值在作用域内保持不变.函数是JavaScript 中唯一有作用域的对象,因此JavaScript的闭包依赖于函数实现,下 ...
- 逻辑很重要:一句sql语句的事,自己却想了半天,绕了个大弯子
问题:系统升级后审核认证信息分别写入两个表,现在需要链接用户表和相应的新旧审核表获取字段值? 钻进胡同里:一直纠结于升级之后的会员信息从新表查,升级之前的数据从旧表查,纠结于根据时间戳分条件判断, 其 ...
- Permission denied (publickey).
问题: ssh-keygen -t rsa -C "youremail@example.com" 若是接连按三次回车,会在-/.ssh下生成 id_rsa, id_rsa.pub ...
- lucene拼写检查模块
Lucene是Apache发布的开源搜索引擎开发工具包,不仅提供了核心的搜索功能,还提供了许多其他功能插件,例如:拼写检查功能模块. 搜索拼写检查模块实现类在lucene-suggest-x.xx.x ...
- Android 4.0 新增的显示数据集的桌面控件
setRemoteAdapter (int viewId, Intent intent):该方法可以使用 Intent 更新 RemoteViews 中viewId 对应的组件. 上面方法的 Inte ...