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 %>
本文介绍在SQL Server中生成ID的方法,包括使用IDENTITY函数创建临时表并填充ID,以及在DataTable中通过编程方式添加ID列并赋值。此外还提供了一个模板示例,展示了如何在模板中使用索引作为ID。
3939

被折叠的 条评论
为什么被折叠?



