I am having a problem finding the child datagrid from the Parent update command. I would like to loop through the values to do some validation.
Code:
Public Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.UpdateCommand
Try
Dim dgTemp As DataGrid = (CType(source, DataGrid))
DataGrid1.EditItemIndex = -1
Dim dgtempSub As DataGrid = (CType(e.Item.FindControl("DataGrid2"), DataGrid))
Dim blType As New Bl.Type(constr)
Dim TempList As New DropDownList
Dim TempValue As Integer
TempList = e.Item.FindControl("ddlID")
TempValue = CInt(TempList.SelectedValue)
Dim dgItem As DataGridItem
For Each dgItem In dgtempSub.Items
If CInt(e.Item.Cells(3).Text) <> TempValue Then
blType.Insert(TempValue, ddlType.SelectedValue)
End If
Next
BindData()
Catch exc As Exception
End Try
End Sub
I get an error on:
Line: For Each dgItem In dgtempSub.Items
Error: "Object reference not set to an instance of an object"
Any help would be appreciated.
Thanks!
NatGreen