S
SK
Hello,
I have a datagrid, which contains another nested
datagrid as a user control. The nested dg is popultated
when the user presses the "+" button in one row for the
main grid. I have a implemented an ItemCommand event which
looks like this:
Select Case e.CommandName
Case "Expand" ' user pressed the + button
' get a reference to the placeholer
Dim ExpandedContent As PlaceHolder = e.Item.Cells
(dgMain.Columns.Count - 1).FindControl("ExpandedContent")
Dim btnExpand As ImageButton = e.Item.Cells(0).FindControl
("btnExpand")
If btnExpand.ImageUrl = "~/Images/Plus.gif" Then
Dim ctrl As UserControl
ctrl = e.Item.Cells(dgMain.Columns.Count -
1).FindControl("GetStylePerStore1")
Dim objGetStylePerStore As GetStylePerStore =
DirectCast(ctrl, GetStylePerStore)
objGetStylePerStore.StartDate = ViewState("StartDate")
....
....
Now the probklem is that from time to time I get the error
Object reference not set to an instance of an object in
the last line of the above code. When I press f5 then it
works again sometimes, but sometimes it doesnt. I am
confused why I am getting this error. Can somebody help?
Thanks
I have a datagrid, which contains another nested
datagrid as a user control. The nested dg is popultated
when the user presses the "+" button in one row for the
main grid. I have a implemented an ItemCommand event which
looks like this:
Select Case e.CommandName
Case "Expand" ' user pressed the + button
' get a reference to the placeholer
Dim ExpandedContent As PlaceHolder = e.Item.Cells
(dgMain.Columns.Count - 1).FindControl("ExpandedContent")
Dim btnExpand As ImageButton = e.Item.Cells(0).FindControl
("btnExpand")
If btnExpand.ImageUrl = "~/Images/Plus.gif" Then
Dim ctrl As UserControl
ctrl = e.Item.Cells(dgMain.Columns.Count -
1).FindControl("GetStylePerStore1")
Dim objGetStylePerStore As GetStylePerStore =
DirectCast(ctrl, GetStylePerStore)
objGetStylePerStore.StartDate = ViewState("StartDate")
....
....
Now the probklem is that from time to time I get the error
Object reference not set to an instance of an object in
the last line of the above code. When I press f5 then it
works again sometimes, but sometimes it doesnt. I am
confused why I am getting this error. Can somebody help?
Thanks