1
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
2
{
3
if (e.Row.RowIndex != -1)
4
{
5
int id = e.Row.RowIndex + 1;
6
e.Row.Cells[0].Text = id.ToString();
7
}
8
}
在GridView中增加了一个自动编号列
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)2
{3
if (e.Row.RowIndex != -1)4
{5
int id = e.Row.RowIndex + 1;6
e.Row.Cells[0].Text = id.ToString();7
}8
}可以详细知道当前页一共有多少记录。
本文介绍了一种在ASP.NET GridView控件中实现自动编号的方法。通过重写RowDataBound事件,在每行加载时设置自增ID,使得网格视图的每一项都能拥有唯一的行号标识。

404

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



