GridView的PagerTemplate分页_weixin_30765475的博客-程序员宅基地

ContractedBlock.gif ExpandedBlockStart.gif Code
<asp:GridView ID="gvProject" runat="server" BorderColor="Gray" Height="20px" Width="98%" AllowPaging="True" AutoGenerateColumns="False" EmptyDataText="没有符合查询条件的数据!" OnDataBound="gvProject_DataBound" OnPageIndexChanging="gvProject_PageIndexChanging" OnRowDataBound="gvProject_RowDataBound" OnRowDeleting="gvProject_RowDeleting">
                                    
<EditRowStyle BackColor="SeaGreen" />
                                    
<SelectedRowStyle BorderColor="SeaGreen" />
                                    
<HeaderStyle BackColor="#718BD6" Font-Size="Small" ForeColor="White" Height="20px" />
                                    
<PagerSettings Mode="NumericFirstLast" />
                                    
<RowStyle Height="16px" />
                                    
<AlternatingRowStyle BackColor="#EDF5FF" />
                                    
<Columns>
                                        
<asp:BoundField DataField="ProjectID" HeaderText="项目ID" Visible="False" />
                                        
<asp:BoundField DataField="ProjectName" HeaderText="项目名称" />
                                        
<asp:BoundField DataField="ProjectStatus" HeaderText="项目状态" />
                                        
<asp:BoundField DataField="ssjd" HeaderText="实施进度" >
                                            
<ItemStyle ForeColor="Red" HorizontalAlign="Center" />
                                        
</asp:BoundField>
                                        
<asp:BoundField DataField="ssBeginDate" HeaderText="实施开始时间" DataFormatString="{0:d}" HtmlEncode="False" />
                                        
<asp:BoundField DataField="ssEndDate" HeaderText="要求结束时间" DataFormatString="{0:d}" HtmlEncode="False" />
                                        
<asp:BoundField DataField="UserName" HeaderText="项目负责人" />
                                        
<asp:HyperLinkField DataNavigateUrlFields="ProjectID" DataNavigateUrlFormatString="ProjectInfo.aspx?ProjectID={0}"
                                            HeaderText
="查看" Text="详细信息" />
                                        
<asp:TemplateField HeaderText="操作">
                                            
<ItemTemplate>
                                                
&nbsp;<asp:ImageButton ID="lbtnDelete" runat="server" CommandName="Delete" ImageUrl="~/Images/drop.gif" />
                                            
</ItemTemplate>
                                        
</asp:TemplateField>
                                    
</Columns>
                                    
<EmptyDataRowStyle ForeColor="Red" />
                                    
                                    
<PagerTemplate>
                                    当前第:
<asp:Label  ID="LabelCurrentPage" runat="server"
 Text
="<%# ((GridView)Container.NamingContainer).PageIndex + 1 %>"></asp:Label>
 页
/共:
<asp:Label ID="LabelPageCount" runat="server"
 Text
="<%# ((GridView)Container.NamingContainer).PageCount %>"></asp:Label> 页
 
 
<asp:LinkButton ID="LinkButtonFirstPage" runat="server" CommandArgument="First" CommandName="Page"
 Visible
='<%#((GridView)Container.NamingContainer).PageIndex != 0 %>'>首页</asp:LinkButton>

<asp:LinkButton ID="LinkButtonPreviousPage" runat="server" CommandArgument="Prev" CommandName="Page"
 Visible
='<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>'>上一页</asp:LinkButton>

<asp:LinkButton ID="LinkButtonNextPage" runat="server" CommandArgument="Next" CommandName="Page"
 Visible
='<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>'>下一页</asp:LinkButton>

<asp:LinkButton ID="LinkButtonLastPage" runat="server" CommandArgument="Last" CommandName="Page"
 Visible
='<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>'>尾页</asp:LinkButton>
  转到第
<asp:textbox id="txtNewPageIndex" runat="server" width="20px" text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>' />
<asp:linkbutton id="btnGo" runat="server" causesvalidation="False" commandargument="-1" commandname="Page" text="GO" /> 
                                    
</PagerTemplate>
                                    
                                
</asp:GridView>

 

ContractedBlock.gif设置后台分页事件PageIndexChanging:

ExpandedBlockStart.gif
protected void gvProject_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        
//gvProject.PageIndex = e.NewPageIndex;
        
//this.BindProjectList();
        GridView theGrid = sender as GridView; // refer to the GridView
        int newPageIndex = 0;
        
if (-2 == e.NewPageIndex)
        { 
// when click the "GO" Button
            TextBox txtNewPageIndex = null;
            
//GridViewRow pagerRow = theGrid.Controls[0].Controls[theGrid.Controls[0].Controls.Count - 1] as GridViewRow; // refer to PagerTemplate
            GridViewRow pagerRow = theGrid.BottomPagerRow; //GridView较DataGrid提供了更多的API,获取分页块可以使用BottomPagerRow 或者TopPagerRow,当然还增加了HeaderRow和FooterRow
            
//updated at 2006年月日:15:33
            if (null != pagerRow)
            {
                txtNewPageIndex 
= pagerRow.FindControl("txtNewPageIndex"as TextBox;   // refer to the TextBox with the NewPageIndex value
            }
            
if (null != txtNewPageIndex)
            {
                newPageIndex 
= int.Parse(txtNewPageIndex.Text) - 1// get the NewPageIndex
            }
        }
        
else
        { 
// when click the first, last, previous and next Button
            newPageIndex = e.NewPageIndex;
        }
        
// check to prevent form the NewPageIndex out of the range
        newPageIndex = newPageIndex < 0 ? 0 : newPageIndex;
        newPageIndex 
= newPageIndex >= theGrid.PageCount ? theGrid.PageCount - 1 : newPageIndex;
        
// specify the NewPageIndex
        theGrid.PageIndex = newPageIndex;
        
// rebind the control
        
// in this case of retrieving the data using the xxxDataSoucr control,
        
// just do nothing, because the asp.net engine binds the data automatically
        this.BindProjectList();//数据绑定的方法
    }
 1 <asp:GridView ID="gvProject" runat="server" BorderColor="Gray" Height="20px" Width="98%" AllowPaging="True" AutoGenerateColumns="False" EmptyDataText="没有符合查询条件的数据!" OnDataBound="gvProject_DataBound" OnPageIndexChanging="gvProject_PageIndexChanging" OnRowDataBound="gvProject_RowDataBound" OnRowDeleting="gvProject_RowDeleting">
 2                                     <EditRowStyle BackColor="SeaGreen" />
 3                                     <SelectedRowStyle BorderColor="SeaGreen" />
 4                                     <HeaderStyle BackColor="#718BD6" Font-Size="Small" ForeColor="White" Height="20px" />
 5                                     <PagerSettings Mode="NumericFirstLast" />
 6                                     <RowStyle Height="16px" />
 7                                     <AlternatingRowStyle BackColor="#EDF5FF" />
 8                                     <Columns>
 9                                         <asp:BoundField DataField="ProjectID" HeaderText="项目ID" Visible="False" />
10                                         <asp:BoundField DataField="ProjectName" HeaderText="项目名称" />
11                                         <asp:BoundField DataField="ProjectStatus" HeaderText="项目状态" />
12                                         <asp:BoundField DataField="ssjd" HeaderText="实施进度" >
13                                             <ItemStyle ForeColor="Red" HorizontalAlign="Center" />
14                                         </asp:BoundField>
15                                         <asp:BoundField DataField="ssBeginDate" HeaderText="实施开始时间" DataFormatString="{0:d}" HtmlEncode="False" />
16                                         <asp:BoundField DataField="ssEndDate" HeaderText="要求结束时间" DataFormatString="{0:d}" HtmlEncode="False" />
17                                         <asp:BoundField DataField="UserName" HeaderText="项目负责人" />
18                                         <asp:HyperLinkField DataNavigateUrlFields="ProjectID" DataNavigateUrlFormatString="ProjectInfo.aspx?ProjectID={0}"
19                                             HeaderText="查看" Text="详细信息" />
20                                         <asp:TemplateField HeaderText="操作">
21                                             <ItemTemplate>
22                                                 &nbsp;<asp:ImageButton ID="lbtnDelete" runat="server" CommandName="Delete" ImageUrl="~/Images/drop.gif" />
23                                             </ItemTemplate>
24                                         </asp:TemplateField>
25                                     </Columns>
26                                     <EmptyDataRowStyle ForeColor="Red" />
27                                     
28                                     <PagerTemplate>
29                                     当前第:
30 <asp:Label  ID="LabelCurrentPage" runat="server"
31  Text="<%# ((GridView)Container.NamingContainer).PageIndex + 1 %>"></asp:Label>
32  页/共:
33 <asp:Label ID="LabelPageCount" runat="server"
34  Text="<%# ((GridView)Container.NamingContainer).PageCount %>"></asp:Label> 页
35  
36  <asp:LinkButton ID="LinkButtonFirstPage" runat="server" CommandArgument="First" CommandName="Page"
37  Visible='<%#((GridView)Container.NamingContainer).PageIndex != 0 %>'>首页</asp:LinkButton>
38 
39 <asp:LinkButton ID="LinkButtonPreviousPage" runat="server" CommandArgument="Prev" CommandName="Page"
40  Visible='<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>'>上一页</asp:LinkButton>
41 
42 <asp:LinkButton ID="LinkButtonNextPage" runat="server" CommandArgument="Next" CommandName="Page"
43  Visible='<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>'>下一页</asp:LinkButton>
44 
45 <asp:LinkButton ID="LinkButtonLastPage" runat="server" CommandArgument="Last" CommandName="Page"
46  Visible='<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>'>尾页</asp:LinkButton>
47   转到第
48 <asp:textbox id="txtNewPageIndex" runat="server" width="20px" text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>' />
49 <asp:linkbutton id="btnGo" runat="server" causesvalidation="False" commandargument="-1" commandname="Page" text="GO" /> 
50                                     </PagerTemplate>
51                                     
52                                 </asp:GridView>

转载于:https://www.cnblogs.com/qxw0816/archive/2009/04/20/1439717.html

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_30765475/article/details/97399085

智能推荐

软件设计师考试 | 第八章 算法设计与分析 | 智能优化算法-程序员宅基地

1. 智能优化算法概述优化技术是一种以数学为基础,用于求解各种工程问题优化解的应用技术。20世纪80年代以来,一些新颖的优化算法,如人工神经网络、混沌、遗传算法、进化规划、模拟退火、禁忌搜索及其混合优化策略等,通过模拟或揭示某些自然现象或过程而得到发展,其思想和内容设计数学、物理学、生物进化、人工智能、神经科学和统计力学等方面,为解决复杂问题提供了新的思路和手段。2. 人工神经网络人工神经网络(ANN)是一个以有向图为拓扑结构的动态系统,它通过对连续或断续的输入作状态响应而进行信息处理。人工神经网

语音合成1700多个中文音频_东方佑的博客-程序员宅基地

from aip import AipSpeechimport wave, pygameimport timeimport randomimport os'''pip install baidu-aip调用百度语音合成api将文字转换成音频文件'''def get_video(msg): APP_ID = '17264707' API_KEY = '59xx...

HTTP中的各种头_sunhuwh的博客-程序员宅基地

请求头:请求头字段用于客户端在请求消息中向服务器传递附加信息,主要包括客户端可以接收的数据类型、压缩方法、语言,以及发出请求的超链接所属页面的URL地址等信息。响应头:响应头字段用于服务器在响应消息中向客户端传递附加信息,包括服务程序名、被请求资源需要的认证方式、被请求资源已移动到的新地址等信息。实体头:是实体内容的原信息,描述了实体内容的属性,包括实体信息类型、长度、压缩

电邮地址_电子邮件如何运作?-程序员宅基地

电邮地址First, you use a mail user agent, or MUA to read and send email from your device (such as gmail, or the mail app on Apple devices). These programs are only active when you're using them. 首先,您使用邮件..._如何用email代理国外邮箱地址

列表的操作大全_列表返回值_@alias的博客-程序员宅基地

列表的操作列表相加操作格式:变量 = 列表1 + 列表2结果:新的列表注意:+两侧都要是列表类型# L = [1,2,3]# L1 = [4,5,6]# print(L+L1)列表相乘操作格式:变量 = 列表 * 整数结果:新的列表# L = [1,2,3]# print(L*2)索引操作变量[索引]分片操作格式:变量 = 列表[:] 获取整个列..._列表返回值

随便推点

2、以太坊智能合约开发(宠物收养DApp)_Johnny.Cheung的博客-程序员宅基地

本篇教程将带您完成一个DApp应用 - 宠物商店的收养追踪系统在开始之前,本篇教程需要读者了解基本的以太坊和智能合约的基础知识,并且掌握基础的HTML和JavaScript的知识。在这篇教程中,我们会讲到:1.设置开发环境2.使用Truffle box来创建一个Truffle项目3.编写智能合约4.编译和迁移智能合约5.测试智能合约6.创建与智能合约交互的用户界面7.在浏览器...

初级算法:冒泡排序_冒泡排序for (int i=1;i<n;i++) for (int j=1;j<=n-i;j++)_~^~^的博客-程序员宅基地

冒泡排序是一种比较常用的基础的排序算法,冒泡排序的基本思想是:每次比较两个相邻的元素,如果它们的顺序错误就把它们交换 过来。 下列是以从大到小排列为例讲解。因为是按照从大到小排列所以越小的越靠后面该算法是通过循环嵌套实现的,首先外循环表示有n个数需要排序,因为是n个数所以只需要循环n-1次就可以了,外循环每循环一次就表示确定了一个数字的位置。而内循环则是从头开始将相邻的两个数进行比较,因为是按照从大到小的顺序排列所以两个数比较,小的数在后面,等到内循环一次执行完毕后表示该数字就是现在的位置就是它按照从大_冒泡排序for (int i=1;i

sqlserver复制oracle的表,sqlserver 复制表 复制数据库存储过程的方法_甜品专家的博客-程序员宅基地

这篇文章主要为大家详细介绍了sqlserver 复制表 复制数据库存储过程的方法,具有一定的参考价值,可以用来参考一下。感兴趣的小伙伴,下面一起跟随512笔记的小编两巴掌来看看吧!在目前的工作中需要解决复制整个SqlServer数据库的问题,复制的内容包括数据库大纲、数据库中的存储过程、函数、表结构、主外键关系以及表中的所有数据等,也就是说copy版本与原数据库一模一样。经过一段时间的摸索,找到的..._sqlserver定时增量复制oracle数据

字符串编码:ASCII、GB系列、Unicode、UTF-8_Cacra的博客-程序员宅基地

对字符串编码进行汇总和区别编码的由来:计算机自己能理解的“语言”是二进制数,最小的信息标识是二进制数,8个二进制位表示一个字节;而我们人类所能理解的语言文字则是一套由英文字母、汉语汉字、标点符号字符、阿拉伯数字等等很多的字符构成的字符集。如果要让计算机来按照人类的意愿进行工作,则必须把人类所使用的这些字符集转换为计算机所能理解的二进制码,这个过程就是编码,他的逆过程称为解码。最..._字符串编码

vue2.x自定义组件上使用v-model指令_vue2 v-model.total_FLTmiao的博客-程序员宅基地

我们都知道v-model是双向数据绑定经常用到的指令,今天学习到在组件上使用v-model指令,感觉还挺不错的,分享一下总数{{total}}Vue.component('my-component',{template:'+1',data:function(){return {counter:0}},methods:{handleClick:_vue2 v-model.total

LFS,编译自己的Linux系统 - 编译临时系统_weixin_30398227的博客-程序员宅基地

LFS,编译自己的Linux系统 - 编译临时系统 编译GCC-4.8.2 PASS 1解压并重命名cd /mnt/lfs/sourcestar -Jxf ../mpfr-3.1.2.tar.xzmv mpfr-3.1.2 mpfrtar -Jxf ../gmp-5.1.3.tar.zxmv gmp-5.1.3 gmptar -z...

推荐文章

热门文章

相关标签