双击GridView的OnRowDataBound事件;
在后台的GridView1_RowDataBound()方法添加代码,最后代码如下所示:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex != -1)
        {
            int id = e.Row.RowIndex + 1;
            e.Row.Cells[0].Text = id.ToString();
        }

    }

注意这时最好把前台的第一列的表头该为“编号”,因为以前的第一列被“吃掉”了。

相关文章:

  • 2021-07-04
  • 2021-12-22
  • 2021-09-06
  • 2022-12-23
  • 2022-01-04
  • 2021-10-01
猜你喜欢
  • 2022-03-02
  • 2021-10-10
  • 2022-03-03
  • 2022-12-23
  • 2021-11-07
相关资源
相似解决方案