Why can't I find the node

mgmhicks
mgmhicks used Ask the Experts™
on
I have a need to change the navigate URL of a treenode depending on the user group.  Here is the code I am using to find the node.

Dim myNode As New TreeNode
Dim myTest As String = "Carpet/Vinyl Install Dates"
myNode = TreeView1.FindNode(Server.HtmlEncode(mytest))
myNode.NavigateUrl = "~/Inspections/frmInstallDates2.aspx"

Open in new window


When I look at the locals  I can see this.


treeview1.Nodes(6).ValuePath      "Carpet/Vinyl Install Dates"      String

Yet the code above does not find the node.  Any ideas.

thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2015

Commented:
Have you tried without the Server.HtmlEncode call?

Author

Commented:
Isn't that what I am doing in the code I sent?

myNode = TreeView1.FindNode(Server.HtmlEncode(mytest))


If it helps this code is on a master page
Most Valuable Expert 2011
Top Expert 2015

Commented:
I am asking if you have removed that bit, and tried it simply as:

myNode = TreeView1.FindNode(mytest)

Open in new window

Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Author

Commented:
i'm sorry yea, that didn't work either.  Weird, cause node(6) has that valuepath
Commented:
this is what I ended up doing and this works.

 If mWaterford = True Then
                For Each myNode In TreeView1.Nodes
                    If myNode.ValuePath = "Carpet/Vinyl Install Dates" Then
                        myNode.NavigateUrl = "~/Inspections/frmInstallDates2.aspx"
                    Else
                    End If
                Next
            Else
                For Each myNode In TreeView1.Nodes
                    If myNode.ValuePath = "Carpet/Vinyl Install Dates" Then
                        myNode.NavigateUrl = "~/Inspections/frmInstallDates.aspx"
                    Else

                    End If
                Next
            End If
Most Valuable Expert 2012
Top Expert 2014

Commented:
I know you have got it working now but when you were trying to use FindNode, was PathSeparator property of the treeview set to "/"?

Author

Commented:
yes it is set to "/"

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial