AutoInc 行号

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
   if (e.Row.RowType == DataControlRowType.DataRow) //如果是数据行
   {
      GridView grid = sender as GridView; //取当前操作的GridView
      int rowNo = e.Row.RowIndex+1; //根据行索引加1取行号
      e.Row.Cells[0].Text = rowNo.ToString();//设置第一列的值为行号
   }
}

posted @ 2013-01-19 16:56  yellowshorts  阅读(110)  评论(0编辑  收藏  举报