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 ...
随机推荐
- ASP.NET C#使用JavaScriptSerializer实现序列化与反序列化得到JSON
在JavaScriptSerializer中,我们可以看到下面可以使用的方法或者构造函数,它们都是实例方法: Member Description JavaScriptSerializer() 构造函 ...
- C# Wpf异步修改UI,多线程修改UI(二)
1.使用定时器异步修改 这是相对比较简单的方法 在Wpf中定时器使用DiapatcherTimer,不使用Timer原因: 在一个应用程序中,Timer会重复生成time事件,而DispatcherT ...
- 控制器View的加载过程
1.控制器内部的view是延迟加载 1> 用到时再加载2> 加载完毕后会调用控制器的viewDidLoad方法 2.创建控制器的方式 1> 直接通过代码创建OneViewContro ...
- model 和 view 实现思考
采用model.view = view 和 view.model=model 进行双向绑定,还有一种方案是采用id号进行绑定,viewmodel的views 和 models 属性存放所有的id 映 ...
- 【USACO 1.5.2】回文质数
[题目描述] 因为151既是一个质数又是一个回文数(从左到右和从右到左是看一样的),所以 151 是回文质数. 写一个程序来找出范围[a,b](5 <= a < b <= 100,0 ...
- 【COGS495】窗口
[问题描述] 给你一个长度为N的数组,一个长为K的滑动的窗体从最左移至最右端,你只能见到窗口的K个数,每次窗体向右移动一位,如下表: Window position Min value Max val ...
- canvas 背景填充
这儿介绍canvas的ccreatePattern函数, context.createPattern(Image,"repeat"),还可以repeat-x,reapter-y 还 ...
- css position 相对定位
<html> <head> <style type="text/css"> h2.pos_left { position:relative; l ...
- 转:Python 与 Excel 不得不说的事
数据处理是 Python 的一大应用场景,而 Excel 则是最流行的数据处理软件.因此用 Python 进行数据相关的工作时,难免要和 Excel 打交道. 如果仅仅是要以表单形式保存数据,可以借助 ...
- 折半插入排序(Binary Insertion Sort)的C语言实现
原创文章,转载请注明来自钢铁侠Mac博客http://www.cnblogs.com/gangtiexia 折半插入排序(Binary Insertion Sort)的基本思想是将新记录插入到已经 ...