欢迎访问我的博客 https://javascript.shop

datalist、repearter、gridview显示行号的三种方法 或者是获取datalist行id

原文发布时间为:2009-05-06 —— 来源于本人的百度文章 [由搬家工具导入]

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 %>   最喜欢的是这种绑定的方法,获取行id也可以在前台这样绑定。

<tr id="<%#Container.ItemIndex+1%>" 。。。。。。。

===================================

gridview是用这个   Container.DataItemIndex+1

posted @ 2017-07-12 00:05  孑孓子  阅读(213)  评论(0编辑  收藏  举报
欢迎访问我的博客 https://javascript.shop