zoukankan      html  css  js  c++  java
  • GridView 加排序序号(正序,倒序)

     

    (正序)

    方法一(不带分页):

    <asp:TemplateField HeaderText="序号">
            <ItemTemplate>
    <%#(Container as GridViewRow).RowIndex + 1%>
           </ItemTemplate>
    </asp:TemplateField>

    方法二(带分页):
    <asp:TemplateField HeaderText="序号">
           <ItemTemplate>
                <%# this.GridView1.PageIndex * this.GridView1.PageSize + Container.DataItemIndex + 1%>
           </ItemTemplate>
    </asp:TemplateField>

    (倒序)

    方法一(不带分页):

    <asp:TemplateField HeaderStyle-Width="30px" HeaderText="序号" ItemStyle-HorizontalAlign="center">
         <ItemTemplate>
             <asp:Label ID="Label1" runat="server" Text='<%#((Container as GridViewRow).DataItem as System.Data.DataRowView).Row.Table.Rows.Count - (Container as GridViewRow).RowIndex%>'></asp:Label>
         </ItemTemplate>
    </asp:TemplateField>

    方法二(带分页):

    <asp:TemplateField HeaderStyle-Width="30px" HeaderText="序号" ItemStyle-HorizontalAlign="center">
         <ItemTemplate>
             <asp:Label ID="Label1" runat="server" Text='<%#((Container as GridViewRow).DataItem as System.Data.DataRowView).Row.Table.Rows.Count - (Container as GridViewRow).RowIndex - (this.gviewList.PageIndex) * this.gviewList.PageSize%>'></asp:Label>
         </ItemTemplate>
    </asp:TemplateField>

  • 相关阅读:
    centos安装vim
    thrift学习之二----学习资料积累
    thrift学习之一-------介绍
    组合模式
    一致性哈希算法(consistent hashing)
    php配置php-fpm启动参数及配置详解
    error while loading shared libraries的解決方法
    数据结构之二叉树
    768、最多能完成排序的块(贪心算法)
    VS code 配置C++编译环境
  • 原文地址:https://www.cnblogs.com/kingboy2008/p/2312735.html
Copyright © 2011-2022 走看看