Reputation: 2534
I am trying to hide a panel based on values, using server side code.
Server Side Code does execute
Public Sub CustomerDataSource_Selected(ByVal source As Object, ByVal e As ObjectDataSourceStatusEventArgs)
Dim DisplayPanel As Boolean
DisplayPanel = False
If e.ReturnValue IsNot Nothing Then
If e.ReturnValue(0).x1 < e.ReturnValue(0).x2 Then
DisplayPanel = True
End If
End If
Dim FPanel As Panel = CType(FormView.FindControl("FuturePanel"), Panel)
FPanel.Visible = DisplayPanel 'here is the problem...
End Sub
I get the exception below because the sub "CustomerDataSource_Selected" is invoked by the ObjectDataSource, which has no access to the form's Control Collections in the code above :
Object reference not set to an instance of an object.
How can I hide the panel using the current sub, which needs access to the control collection?
Remember that the sub is invoked from the ObjectDataSource?
Is this possible?
Upvotes: 0
Views: 39
Reputation: 2112
Looks like
Dim FPanel As Panel = CType(FormView.FindControl("FuturePanel"), Panel)
Is not getting the control. (FPanel == Null)
Try this...
Dim FPanel As Panel = CType(FormView1.Row.Cells[0].FindControl("FuturePanel"), Panel)
Upvotes: 1