GridView中加入//实现分页
要在GridView中加入//实现分页
AllowPaging="true" PageSize="10"
// 分页时触发的事件
protectedvoid gvwDesignationName_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvwDesignationName.PageIndex=e.newIndex;
bingDesignatioonName();
}
这里我给出一个通用显示分页的模板(网上搜的,自己给出注释)
对应该事件中代码为
<PagerTemplate>
当Ì¡À前¡ã第̨²:
<asp:Label ID="LabelCurrentPage" runat="server" Text="<%# ((GridView)Container.NamingContainer).PageIndex + 1
%>"></asp:Label>
页°3/共2:
<asp:Label ID="LabelPageCount" runat="server" Text="<%#
((GridView)Container.NamingContainer).PageCount %>"></asp:Label>
页°3
<asp:LinkButton ID="LinkButtonFirstPage" runat="server"
CommandArgument="First"
CommandName="Page"
Visible='<%#((GridView)Container.NamingContainer).PageIndex != 0
%>'>首º¡Á页°3</asp:LinkButton>
<asp:LinkButton ID="LinkButtonPreviousPage" runat="server"
CommandArgument="Prev"
CommandName="Page" Visible='<%# ((GridView)Container.NamingContainer).PageIndex !=
0 %>'>上¦?一°?页°3</asp:LinkButton>
<asp:LinkButton ID="LinkButtonNextPage" runat="server"
CommandArgument="Next"
CommandName="Page"
Visible='<%# ((GridView)Container.NamingContainer).PageIndex !=
((GridView)Container.NamingContainer).PageCount - 1 %>'>下?一°?页°3</asp:LinkButton>
<asp:LinkButton ID="LinkButtonLastPage" runat="server"
CommandArgument="Last"
CommandName="Page"
Visible='<%# ((GridView)Container.NamingContainer).PageIndex !=
((GridView)Container.NamingContainer).PageCount - 1 %>'>尾2页°3</asp:LinkButton>
转Áa到Ì?第̨²
<asp:TextBox ID="txtNewPageIndex" runat="server" Width="20px" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>' />页°3
<asp:LinkButton ID="btnGo" runat="server" CausesValidation="False" CommandArgument="-2"
CommandName="Page" Text="GO" />
</PagerTemplate>
protected void gvwDesignationName_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
// 得到该控件
GridView theGrid = sender as GridView;
int newPageIndex = 0;
if (e.NewPageIndex==-3)
{
//点击了Go按钮
TextBox txtNewPageIndex = null;
//GridView较DataGrid提供了更多的API,获取分页块可以使用BottomPagerRow 或者TopPagerRow,当然还增加了HeaderRow和FooterRow
GridViewRow pagerRow = theGrid.BottomPagerRow;
if (pagerRow != null)
{
//得到text控件
txtNewPageIndex = pagerRow.FindControl("txtNewPageIndex") as TextBox;
}
if ( txtNewPageIndex!= null)
{
//得到索引
newPageIndex = int.Parse(txtNewPageIndex.Text) - 1;
}
}
else
{
//点击了其他的按钮
newPageIndex = e.NewPageIndex;
}
//防止新索引溢出
newPageIndex = newPageIndex < 0 ? 0 : newPageIndex;
newPageIndex = newPageIndex >= theGrid.PageCount ? theGrid.PageCount - 1 : newPageIndex;
//得到新的值
theGrid.PageIndex = newPageIndex;
//重新绑定
bingDesignatioonName();
}
要在GridView中加入//实现分页
AllowPaging="true" PageSize="10"
// 分页时触发的事件
protectedvoid gvwDesignationName_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvwDesignationName.PageIndex=e.newIndex;
bingDesignatioonName();
}
这里我给出一个通用显示分页的模板(网上搜的,自己给出注释)
对应该事件中代码为
<PagerTemplate>
当Ì¡À前¡ã第̨²:
<asp:Label ID="LabelCurrentPage" runat="server" Text="<%# ((GridView)Container.NamingContainer).PageIndex + 1
%>"></asp:Label>
页°3/共2:
<asp:Label ID="LabelPageCount" runat="server" Text="<%#
((GridView)Container.NamingContainer).PageCount %>"></asp:Label>
页°3
<asp:LinkButton ID="LinkButtonFirstPage" runat="server"
CommandArgument="First"
CommandName="Page"
Visible='<%#((GridView)Container.NamingContainer).PageIndex != 0
%>'>首º¡Á页°3</asp:LinkButton>
<asp:LinkButton ID="LinkButtonPreviousPage" runat="server"
CommandArgument="Prev"
CommandName="Page" Visible='<%# ((GridView)Container.NamingContainer).PageIndex !=
0 %>'>上¦?一°?页°3</asp:LinkButton>
<asp:LinkButton ID="LinkButtonNextPage" runat="server"
CommandArgument="Next"
CommandName="Page"
Visible='<%# ((GridView)Container.NamingContainer).PageIndex !=
((GridView)Container.NamingContainer).PageCount - 1 %>'>下?一°?页°3</asp:LinkButton>
<asp:LinkButton ID="LinkButtonLastPage" runat="server"
CommandArgument="Last"
CommandName="Page"
Visible='<%# ((GridView)Container.NamingContainer).PageIndex !=
((GridView)Container.NamingContainer).PageCount - 1 %>'>尾2页°3</asp:LinkButton>
转Áa到Ì?第̨²
<asp:TextBox ID="txtNewPageIndex" runat="server" Width="20px" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>' />页°3
<asp:LinkButton ID="btnGo" runat="server" CausesValidation="False" CommandArgument="-2"
CommandName="Page" Text="GO" />
</PagerTemplate>
protected void gvwDesignationName_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
// 得到该控件
GridView theGrid = sender as GridView;
int newPageIndex = 0;
if (e.NewPageIndex==-3)
{
//点击了Go按钮
TextBox txtNewPageIndex = null;
//GridView较DataGrid提供了更多的API,获取分页块可以使用BottomPagerRow 或者TopPagerRow,当然还增加了HeaderRow和FooterRow
GridViewRow pagerRow = theGrid.BottomPagerRow;
if (pagerRow != null)
{
//得到text控件
txtNewPageIndex = pagerRow.FindControl("txtNewPageIndex") as TextBox;
}
if ( txtNewPageIndex!= null)
{
//得到索引
newPageIndex = int.Parse(txtNewPageIndex.Text) - 1;
}
}
else
{
//点击了其他的按钮
newPageIndex = e.NewPageIndex;
}
//防止新索引溢出
newPageIndex = newPageIndex < 0 ? 0 : newPageIndex;
newPageIndex = newPageIndex >= theGrid.PageCount ? theGrid.PageCount - 1 : newPageIndex;
//得到新的值
theGrid.PageIndex = newPageIndex;
//重新绑定
bingDesignatioonName();
}
GridView中加入//实现分页的更多相关文章
- 在DevExpress程序中使用Winform分页控件直接录入数据并保存
一般情况下,我们都倾向于使用一个组织比较好的独立界面来录入或者展示相关的数据,这样处理比较规范,也方便显示比较复杂的数据.不过在一些情况下,我们也可能需要直接在GridView表格上直接录入或者修改数 ...
- ASP.net中GridView中增加一行记录并默认显示为编辑状态
//添加 protected void Button1_Click(object sender, EventArgs e) { DataSet ds = (DataSet)pa.GetDataSet( ...
- GridView中显示时间日期格式问题
以下都是GridView基本常用的日期,时间格式 形式 语法 结果 注释 数字 {0:N2} 12.36 数字 {0:N0} 13 货币 {0:c2} $12.36 货币 {0:c4} $ ...
- 实现CheckBox的三种选中状态(全选、半选、不选)在GridView中模拟树形的功能
度娘了很多帖子,只说三种状态要用图片替换来做,但没找到有用的例子,被逼自己写了一个 三方控件肯定是很多的,如jstree,可以直接用 由于公司的UDS限制,不能上传图片,只能文字说明了. 就是要在gr ...
- Gridview中几个Button的应用
gridview中有三种方式添加button的应用,CommandField.ButtonField.TemplateField中加Button这三种方式.三种方式都可以实现同样的功能,但在实现某些功 ...
- DEV控件中GridView中的复选框与CheckBox实现联动的全选功能
最初的界面图如图1-1(全选框ID: cb_checkall DEV控件名称:gcCon ): 要实现的功能如下图(1-2 1-3 1-4)及代码所示: 图1-2 图1-3 图1-4 O(∩_∩ ...
- SpringMVC结合easyUI中datagird实现分页
SpringMVC结合easyUI中datagird实现分页 DataGrid以表格形式展示数据,并提供了丰富的选择.排序.分组和编辑数据的功能支持.轻量级,单元格合并.多列标题.冻结列和页脚只是其中 ...
- .net中从GridView中导出数据到excel(详细)
1,创建数据源 找到要导出的GridView中的数据. 2,重写VerifyRenderingInServerForm方法. public override void VerifyRenderingI ...
- GridView中的GridView1_RowCommand事件
GridView1_RowCommand事件是GridView中生成事件时激发 比如说页面中有一个按钮给他设置CommandName属性 <asp:Button ID="btnCheH ...
随机推荐
- SoapUI这么好,舍得不用吗?
之前尝试去学习哈SoapUI, 安装都报错,直接拖黑不用,对java开发的产品本身不感冒 后来工作上,和老外沟通,发现他们不会用xmlspy,只会SoapUI,心里都想,不学习看来不方便,然后都安装了 ...
- 3171. [TJOI2013]循环格【费用流】
Description 一个循环格就是一个矩阵,其中所有元素为箭头,指向相邻四个格子.每个元素有一个坐标(行,列),其中左上角元素坐标为(0,0).给定一个起始位置(r,c) ,你可以沿着箭头防线在格 ...
- 【[SDOI2014]数数】
被慎老师教育数位\(dp\)怎么写了 看来我数位\(dp\)的写法太落后了 这道题很显然就是一个\(AC\)自动机上的数位\(dp\),按照套路 我们可以设计\(dp[i][j][0/1]\)表示匹配 ...
- Mac安装软件时提示已损坏的解决方法
问题描述 最近安装从网上下载的软件,安装完之后打开提示xxx已损坏,打不开,软件无法打开. 其实,这是新系统(macOS Sierra 10.12.X)新安全机制的锅,它默认不允许用户自行下载安装应用 ...
- OKHttp3学习
转载 Okhttp3基本使用 基本使用——OkHttp3详细使用教程 一.简介 HTTP是现代应用常用的一种交换数据和媒体的网络方式,高效地使用HTTP能让资源加载更快,节省带宽. OkHttp是一个 ...
- SpringBoot实战(九)之Validator
表单验证,是最为常见的,今天演示的是利用hibernate-validtor进行校验,有的时候,虽然前端方面通过jQuery或者require.js校验框架进行校验,可以减轻服务器的压力和改善用户体验 ...
- DataFrame查找
一 通过索引取数据 (ix/loc/iloc) loc (根据索引名称取数据 , 适合多列) iloc (根据索引序号取数据, 适合多列) at (和loc类似,只用于取单列, 性能更好) ia ...
- 解密蓝牙mesh系列
解密蓝牙mesh系列 https://mp.weixin.qq.com/s/KdVhkgcmHIboA0xPFqFCgQ 1.NRF52832 & NRF52840 BLE mesh 协议栈 ...
- 一点一点看JDK源码(〇)
一点一点看JDK源码(〇) liuyuhang原创,未经允许进制转载 写在前面: 几乎所有的大神都会强调看源码,也强调源码的重要性: 但是如何看源码,源码看什么?看了什么用?看了怎么用? 困扰很多人, ...
- Android程序项目结构(二)
利用Android Studio创建完第一个Hello World项目后,我们会看到使用project模式的项目结构. 一..gradle和.idea 这两个目录放置的是Android Studio自 ...