zoukankan      html  css  js  c++  java
  • GridView分页操作

    1.html

                                <PagerStyle HorizontalAlign="Center" />
                                <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>

    2.后台代码

            protected void gvAuthManagement_PageIndexChanging(object sender, GridViewPageEventArgs e)
            {
                GridView theGrid = sender as GridView;
                int newPageIndex = 0;
                if (e.NewPageIndex == -2)
                {
                    TextBox txtNewPageIndex = null;
                    GridViewRow pagerRow = theGrid.BottomPagerRow;
                    if (pagerRow != null)
                    {
                        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;
                InfoList = AuthorizationBiz.Query(new AuthorizationInfo());
                Bind(InfoList);
            }
  • 相关阅读:
    dedecms调用指定栏目名称,链接
    修改 Dedecms 文档文章标题长度的方法
    dedeCMS的arclist标签中limit是什么意思
    DedeCms织梦系统[field:description /]标签如何限制字数?
    mysql 如何更改root密码
    允许phpmyadmin空密码登录的配置方法
    Apache启动失败解决办法
    Apache 配置多域名、二级域名
    使用Auto Layout中的VFL(Visual format language)--代码实现自动布局
    使用UITextField自动格式化银行卡号
  • 原文地址:https://www.cnblogs.com/slu182/p/4258959.html
Copyright © 2011-2022 走看看