Hello,
I have a DataGrid bound to a DataSet, with one column being a ButtonColumn. When the user clicks on the button, the code goes to the ItemCommand event handler where I try to use the index position of the button on the grid to access data from the DataSet fields.
The code is the following:
Private Sub ReserveClicked(ByVal sender As System.Object, ByVal e As DataGridCommandEventArgs) Handles dgApptList.ItemCommand
'This is where I get the row index of the button clicked
Dim GridRow As Integer = e.Item.ItemIndex
'Then I try to assign a field value from the undelying bound DataSet (ApptGrdDS) to a string
Dim GrDS As String = ApptGrdDS.Tables("Appointment").Rows(GridRow).Item("Slot").ToString
But when I run it I get:
"Object reference not set to an instance of an object" on the Dim GrDS... line.
Can I not access the DataSet object in the ReserveClicked ItemCommand event handler procedure? Is there another way it needs to be referenced? Any ideas?
Much appreciated
I have a DataGrid bound to a DataSet, with one column being a ButtonColumn. When the user clicks on the button, the code goes to the ItemCommand event handler where I try to use the index position of the button on the grid to access data from the DataSet fields.
The code is the following:
Private Sub ReserveClicked(ByVal sender As System.Object, ByVal e As DataGridCommandEventArgs) Handles dgApptList.ItemCommand
'This is where I get the row index of the button clicked
Dim GridRow As Integer = e.Item.ItemIndex
'Then I try to assign a field value from the undelying bound DataSet (ApptGrdDS) to a string
Dim GrDS As String = ApptGrdDS.Tables("Appointment").Rows(GridRow).Item("Slot").ToString
But when I run it I get:
"Object reference not set to an instance of an object" on the Dim GrDS... line.
Can I not access the DataSet object in the ReserveClicked ItemCommand event handler procedure? Is there another way it needs to be referenced? Any ideas?
Much appreciated