Private Sub DataGrid_yuangong_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid_yuangong.ItemCommand
Dim zhigong_hao As Integer
Dim index As Integer = DataGrid_yuangong.CurrentPageIndex
Dim dtable As DataTable = New DataTable
dtable = CType(Me.DataGrid_yuangong.DataSource, DataTable)
zhigong_hao = dtable.Rows(0)("id")
Response.Write(zhigong_hao)
End Subzhigong_hao = dtable.Rows(0)("id") 这行有错误
错误信息 :Object reference not set to an instance of an object.
Dim zhigong_hao As Integer
Dim index As Integer = DataGrid_yuangong.CurrentPageIndex
Dim dtable As DataTable = New DataTable
dtable = CType(Me.DataGrid_yuangong.DataSource, DataTable)
zhigong_hao = dtable.Rows(0)("id")
Response.Write(zhigong_hao)
End Subzhigong_hao = dtable.Rows(0)("id") 这行有错误
错误信息 :Object reference not set to an instance of an object.
看一下CType(Me.DataGrid_yuangong.DataSource, DataTable)是否返回了null值
把后面的Id去了。