在gridview1中加入序号列
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
'在gridview1中加入序号
If e.Row.RowIndex > -1 Then
e.Row.Cells(0).Text = e.Row.RowIndex + 1
'如果包含分页则
'e.Row.Cells(0).Text = GridView1.PageIndex * GridView1.PageSize + e.Row.RowIndex + 1
End If
End Sub
'更方便的
'直接在模板列中label绑定 (Container.DataItemIndex+1).tostring