惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
博客园_首页
雷峰网
雷峰网
V
V2EX
博客园 - 司徒正美
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - Franky
月光博客
月光博客
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
T
Tailwind CSS Blog
小众软件
小众软件
博客园 - 叶小钗
美团技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
Apple Machine Learning Research
Apple Machine Learning Research
IT之家
IT之家
MyScale Blog
MyScale Blog
Blog — PlanetScale
Blog — PlanetScale
大猫的无限游戏
大猫的无限游戏
Jina AI
Jina AI
人人都是产品经理
人人都是产品经理
H
Help Net Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

博客园 - 北溟鱼逍遥游

datepart in ssis Mac再建管理员帐户 [error] option strict on disallow late binding [SSIS 2005]SSIS Error The AcquireConnection method call to the connection manager failed with error code 0xC0202009 [SSIS 2005]the script task can not run this edition of integration service 团队的脊梁 求:C# 中nowarn 的 attribute msn group 转 大师 Proj summary Thinking snippets SQL server 2005 Enterprise Edition can't support AMD sepron 2500+ Can't found the specified domain: Web access LDAP Server - 北溟鱼逍遥游 Singleton C++/STL 笔记 经典:自己收藏 Understand office model Close window without alert 给软件开发经理的建议
DataGrid Item auto-generate serial number
北溟鱼逍遥游 · 2005-01-06 · via 博客园 - 北溟鱼逍遥游

when AllowPaging=False

<asp:DataGrid id="DataGrid1" runat="server">
    
<Columns>
     
<asp:TemplateColumn>
      
<ItemTemplate>
       
<%# Container.ItemIndex + 1%>
      
</ItemTemplate>
     
</asp:TemplateColumn>
    
</Columns>
 
</asp:DataGrid>


or

<asp:DataGrid id="DataGrid1" runat="server">
    
<Columns>
     
<asp:TemplateColumn>
      
<ItemTemplate>
       
<%this.DataGrid1.Items.Count + 1%>
      
</ItemTemplate>
     
</asp:TemplateColumn>
    
</Columns>
 
</asp:DataGrid>


AllowPaging
="True"

<asp:DataGrid id="DataGrid1" runat="server" AllowPaging="True">
    
<Columns>
     
<asp:TemplateColumn>
      
<ItemTemplate>
       
<%this.DataGrid1.CurrentPageIndex * this.DataGrid1.PageSize + Container.ItemIndex + 1%>
      
</ItemTemplate>
     
</asp:TemplateColumn>
    
</Columns>
</asp:DataGrid>


Reverse order:
//have been defined:
private int RowsCount = ds.Tables[0].Rows.Count

asp:DataGrid id="DataGrid1" runat="server" AllowPaging="True">

                            
<Columns>

                                   
<asp:TemplateColumn>

                                          
<ItemTemplate>

                                                 
<%# RowsCount - DataGrid1.CurrentPageIndex * DataGrid1.PageSize - Container.ItemIndex %>

                                          
</ItemTemplate>

                                   
</asp:TemplateColumn>

                            
</Columns>

                     
</asp:DataGrid>