请帮我解释一下,这段代码中没一句代码的意思,谢谢!
 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
         if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[0].Text = Convert.ToString(e.Row.DataItemIndex + 1);
        }
    }
   

解决方案 »

  1.   

    GridView1_RowDataBoundGridView1 的 行绑定事件e.Row.RowType == DataControlRowType.DataRow判断当前行的行类型 是否为 数据行 e.Row.Cells[0].Text 当前行的第一列的文本e.Row.DataItemIndex + 1当前行的行号------------------------------------------
    简单的写法
    <ItemTemplate>
            <%#Container.DataItemIndex + 1 %>
    </ItemTemplate>放在第一列
      

  2.   

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)//判断当前行是否数据行
    {
    e.Row.Cells[0].Text = Convert.ToString(e.Row.DataItemIndex + 1);//将当前行的第一列的文本设置为当前行的行号+1
    }
    }