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

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

智能推荐

python字符串分行输出_Python字符串的5个知识点-程序员宅基地

文章浏览阅读1.4k次。1.使用方法修改字符串的大小写在msg.title()中,msg后面的句点(.)让python对变量msg执行方法title()指定的操作。每个方法后面都跟着一对括号,这是因为方法通常需要额外的信息来完成其工作。这种信息是在括号内提供的。函数title()不需要额外的信息,因此它后面的括号是空的。title()以首字母大写的方式显示每个单词,即将每个单词的首字母都改为大写。这很有用,因为你经常需要..._python字符串分行

React样式策略_jsx中编写classname 为什么要写styles.-程序员宅基地

文章浏览阅读175次。React样式策略_jsx中编写classname 为什么要写styles.

android获取当前按钮文本,从Android中的EditText获取文本点击按钮-程序员宅基地

文章浏览阅读471次。您好我正在使用android中的计算器。 我有一个EditText在wchich不会显示,具体取决于特定号码的点击,例如当用户按1时,它将显示1.现在当用户点击2时,它将显示12等等。从Android中的EditText获取文本点击按钮我有这样的事情public class Main extends Activity implements OnClickListener {public stati..._androidstudio点击按钮获取文本框内容

第3章 信息系统治理_it审计的固有风险-程序员宅基地

文章浏览阅读679次。第3章 信息系统治理_it审计的固有风险

C语言数组详解-程序员宅基地

文章浏览阅读1.2k次,点赞41次,收藏40次。数组是编程中一种基础且重要的数据结构,用于存储一系列相同类型的元素,这些元素在内存中是连续存放的。在 C 语言中,数组可以存储任何数据类型的元素,如整数、浮点数、字符等。了解数组的工作原理及其特性对于编写有效和高效的程序至关重要。

vue使用QrCode生成二维码_qrcode-vue-程序员宅基地

文章浏览阅读2.9k次。1、安装cnpm i qrcodejs2 --save2、在相应的Vue组件中引入qrcode插件import QRCode from "qrcodejs2";3、在html中增加相应的DOM结构<div id="qrcode"></div>4、在methods定义方法 qrcode() { let qrcode = new QRCode("qrcode", { render: "canvas", //也可以替换为table_qrcode-vue

随便推点

解决ThinkPad 笔记本电脑无法连接手动添加的隐藏网络问题-提示“无法连接这个网络”_thinkpad e460安装网卡失败,没法上网-程序员宅基地

文章浏览阅读3.8k次。本人ThinkPad E460,Win10操作系统,因为工作内容,需要在特定的网络中开发,要连接隐藏网络。公司分配的是台式机,给了个2.4g的网卡,5g没到货时,用着是在憋屈,所以就用自己的笔记本连接隐藏5g网。然后按照正常步骤进行:点击网络图标 - 网络和Internet设置 - 网络和共享中心 - 设置新的网络 - 手动连接到无线网络 ...当点击连接时就给反馈:“无法连接这个..._thinkpad e460安装网卡失败,没法上网

YOLOV8安卓端部署_yolov8部署到手机-程序员宅基地

文章浏览阅读1.7k次,点赞5次,收藏31次。之前部署的yolov5-ncnn不支持调用本地摄像头进行在线推理,多少还是感觉遗憾。说实话yolov8-ncnn的部署属实有点割韭菜的嫌疑,这篇博客教你从0部署yolov8到安卓手机。_yolov8部署到手机

举例说明计算机图形学的主要应用领域,计算机图形学-程序员宅基地

文章浏览阅读2.6k次。1、 举例说明计算机图形学的主要应用领域(至少说明5个应用领域)计算机及辅助设计与制造、可视化、图形实时绘制与自然景物仿真、计算机动画、用户接口、计算机艺术2、 分别解释直线生成算法DDA法、中点画线法和Bresenham法的基本原理。 DDA法:设过端点P0(x0 ,y0)、P1(x1 ,y1)的直线段为L(P0 ,P1),则直线段L的斜率L的起点P0的横坐标x0向L的终点P1的横坐标x1步进..._列举有关计算机图形学的应用

python中在一个类中调用另一个类的方法_python中类方法如何调用-程序员宅基地

文章浏览阅读5.3w次,点赞17次,收藏67次。通过实例化一个对象,使一个类能调用另一个类的方法主题代码主题描述老张开车去东北这件事类人实例变量:名字name实例方法:去go_to车实例方法:run代码class Person: def __inti__(self,name): self.name = name def go_to(self,position,type): ''' :par..._python中类方法如何调用

Zookeeper可视化工具PrettyZoo_prettyzoo mac-程序员宅基地

文章浏览阅读2.2w次,点赞9次,收藏13次。文章目录安装创建连接虽然市面上 Zookeeper 的 WEB 管理工具很丰富,但是却很难找到一款满意的图形化客户端。鉴于这样的情况,经过时间的查找,找到了这款管理 Zookeeper 的图形化工具,取名 PrettyZoo,意为:Pretty nice Zookeeper GUI。PrettyZoo 是一个基于 JavaFX 和 Apache Curator 实现的 Zookeeper 图形化工具,该项目完全开源,可以通过 Github 主页查看。github:https://github.com_prettyzoo mac

AD10导出文件【摆位图】【上文中comment不是value值得情况】【DXF结构文件】【低版本protel能打开的原理图、PCB文件】【导出gerber文件无边框】_ad生成gerber文件无边框-程序员宅基地

文章浏览阅读8.4k次。方便焊接的值value文件在焊接过程中最方便的是在图中直接显示元件的值,因为这样即知道了这个是什么元件,也知道了这个元件的具体指,最适合手焊,如下:在AD软件中如果在comment这个属性就是值得情况(protel软件)只要把原件的标号隐藏掉,并显示conment即可,元件属性如下:这时候导出设置如下:导出结果如下:但是这时候的导出结果过于混乱,调整方式是直接隐..._ad生成gerber文件无边框

推荐文章

热门文章

相关标签