I have 2 controls inside a form
<aspropDownList id="MyDDL" runat="server" OnSelectedIndexChanged="DoStuff()">
and
<asp:treeview id="MyTree" runat="server" />
So changing my dropdownlist value OR click on a node in my tree can submit my form.
I have a line in my Page_Load() that accesses
MyTree.SelectedNode.Parent.Text
Obviously when the form is submitted via a click on a node in the tree this works fine but if it hits this line because of a submit by selecting a dropdown list value this line throws an error:
System.NullReferenceException: Object reference not set to an instance of an object
I can't seem to evaluate my expression to NULL in order to handle this.
If(MyTree.SelectedNode.Parent.Text Is Nothing)Then
.... ' does not work
End if
If(String.IsNullOrEmpty(MyTree.SelectedNode.Parent.Text))Then
.... ' does not work
End if
DBNull is for Datasets, how can I evaluate the expression to grab the NULL. I would like to be able to do this without Try/Catch for now
Thanks
<aspropDownList id="MyDDL" runat="server" OnSelectedIndexChanged="DoStuff()">
and
<asp:treeview id="MyTree" runat="server" />
So changing my dropdownlist value OR click on a node in my tree can submit my form.
I have a line in my Page_Load() that accesses
MyTree.SelectedNode.Parent.Text
Obviously when the form is submitted via a click on a node in the tree this works fine but if it hits this line because of a submit by selecting a dropdown list value this line throws an error:
System.NullReferenceException: Object reference not set to an instance of an object
I can't seem to evaluate my expression to NULL in order to handle this.
If(MyTree.SelectedNode.Parent.Text Is Nothing)Then
.... ' does not work
End if
If(String.IsNullOrEmpty(MyTree.SelectedNode.Parent.Text))Then
.... ' does not work
End if
DBNull is for Datasets, how can I evaluate the expression to grab the NULL. I would like to be able to do this without Try/Catch for now
Thanks