Gridview添加行号

 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();
        }

    }

原文地址:https://www.cnblogs.com/freexiaoyu/p/1207522.html