DataList显示行号的三种方法

来源:互联网 发布:数据挖掘 算法和原理 编辑:程序博客网 时间:2024/05/22 17:30

1. if you are using SQL Server, try


 程序代码
select identity(int,1,1) as 'id', * into #mytemp from YourTable
select * from #mytemp


2. you could add a column to the DataTable:


 程序代码
DataTable1.Columns.Add("ID",typeof(int));
int i=0;
foreach (DataRow dr in DataTable1.Rows)
{
    dr["ID"] = ++i;
}


3. or you can use in your template


 程序代码
<%# Container.ItemIndex+1 %>