• page分页模板


    <PagerTemplate>
                    当前第:
                    
    //((GridView)Container.NamingContainer)就是为了得到当前的控件
                    <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>
                    页
                     
    //如果该分页是首分页,那么该连接就不会显示了.同时对应了自带识别的命令参数CommandArgument
                    <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 %>' />
                    
    //这里将CommandArgument即使点击该按钮e.newIndex 值为3 
                    <asp:LinkButton ID="btnGo" runat="server" CausesValidation="False" CommandArgument="-2"
                        CommandName
    ="Page" Text="GO" />
                
    </PagerTemplate>

    后台代码

     1    protected void gvwDesignationName_PageIndexChanging(object sender, GridViewPageEventArgs e)
     2     {
     3         // 得到该控件
     4         GridView theGrid = sender as GridView;
     5         int newPageIndex = 0;
     6         if (e.NewPageIndex == -3)
     7         {
     8             //点击了Go按钮
     9             TextBox txtNewPageIndex = null;
    10 
    11             //GridView较DataGrid提供了更多的API,获取分页块可以使用BottomPagerRow 或者TopPagerRow,当然还增加了He          aderRow和FooterRow
    12             GridViewRow pagerRow = theGrid.BottomPagerRow;
    13 
    14             if (pagerRow != null)
    15             {
    16                 //得到text控件
    17                 txtNewPageIndex = pagerRow.FindControl("txtNewPageIndex") as TextBox;
    18             }
    19             if (txtNewPageIndex != null)
    20             {
    21                 //得到索引
    22                 newPageIndex = int.Parse(txtNewPageIndex.Text) - 1;
    23             }
    24         }
    25         else
    26         {
    27             //点击了其他的按钮
    28             newPageIndex = e.NewPageIndex;
    29         }
    30         //防止新索引溢出
    31         newPageIndex = newPageIndex < 0 ? 0 : newPageIndex;
    32         newPageIndex = newPageIndex >= theGrid.PageCount ? theGrid.PageCount - 1 : newPageIndex;
    33 
    34         //得到新的值
    35         theGrid.PageIndex = newPageIndex;
    36 
    37         //重新绑定
    38         BindReport(0);
    39     }
  • 相关阅读:
    QPushbutton样式
    qt调动DLL
    QLabel设置行间距
    Qt 5.2.1 applications (32 bit) in CentOS (64 bit with gcc 4.8.2)
    qt设置阴影效果
    ubuntu命令
    How to configure NFS on Linux
    gsoap生成onvif c++源码
    QUrl乱码问题
    QTableWidget自适应标题(铺满、可调节)
  • 原文地址:https://www.cnblogs.com/dongbo19910728/p/3222506.html
Copyright © 2020-2023  润新知