GridView自动编号
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中增加了一个自动编号列![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
可以详细知道当前页一共有多少记录。