Home - Forums-.NET - FlyTreeView (ASP.NET) - Display node on load?

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Display node on load?
Link Posted: 02-Jun-2010 13:08
Hi,
I need to display a certain node when the page loads, via a querystring. The node displayed would change based on the value of the querystring parameter. How can I do that? Any suggestions?

I've looked through the documentation. samples, and the forum and haven't found what I'm looking for.

Thanks!
Will
Link Posted: 03-Jun-2010 01:18
You can create and add nodes programmatically (to flytreeview.Nodes collection)
in Page_Load or where you need.

There is a built-in demo for this.
Link Posted: 03-Jun-2010 10:32
Which demo?

Thanks
Link Posted: 03-Jun-2010 11:01
Oh, I'm sorry there's no such demo for this version of the control.
Anyway it's quite simple:

Just create node like
FlyTreeNode node = new FlyTreeNode();
node.Text = "A node"

FlyTreeView1.Nodes.Add(node);

Every node itself has ChildNodes collection. So you can add child nodes to node and create hierarchy you need.
Link Posted: 03-Jun-2010 14:39
Thanks for the reply!

Is your suggested code placed on the FileSystemNodes page or in the code behind?
Link Posted: 03-Jun-2010 14:55
I guess it would go in the class file huh? :)

Can I pass in the querystring parameter as a value in this line? >>
Public Shared Sub AddNodes(ByVal nodes As FlyTreeNodeCollection, ByVal directoryPath As String)


Something like:
Public Shared Sub AddNodes(ByVal nodes As FlyTreeNodeCollection, ByVal directoryPath As String, ByVal QS as String)


If so, how? I've tried adding it in the directoryPath value but that seems to need to be an empty string that is populated on postback.
Link Posted: 04-Jun-2010 00:11
You can see just the code of AddNodes itself.

What it does - it adds nodes to be populated on demand.

Your case is simpler. So just create nodes and add them to flytreeview.Nodes or somenode.ChildNodes collection.

AddNodes function also utilizes this approach.
It creates a node:
Dim ftn As New FlyTreeNode()
ftn.Text = HttpUtility.HtmlEncode(subDir.Name)
ftn.Value = subDir.Name

and adds it to parent collection of nodes.
In your case it can be FlyTreeView1.Nodes.Add(ftn)
Link Posted: 04-Jun-2010 13:08
No offense, but you skipped my last question about how to get the value to the class file. :)
Link Posted: 05-Jun-2010 09:38
AddNodes is just a sample function that creates nodes, you shouldn't copy.
It uses directoryPath because it creates nodes for provided filesystem directory.
Link Posted: 07-Jun-2010 13:17
My nodes are dynamic and only shown based on the querysting value, so hard coding them in the class file isn't going to work. The names change, folders move, etc.