How to get data from dynamically created treeview
I am using 3rd party ComponentArt for ASP.NET 2.0. Here is the problem I am facing.
I created several ComponentArt.Web.UI.TreeView
at runtime on Page_Load
. Now on clicking the button, I want to get the values ββof the selected nodes in the tree structure.
Can anyone please help?
First, I am assuming the MultipleSelectEnabled is set to true to allow multiple nodes to be selected in the TreeView.
If you have this, you can use the MultipleSelectedNodes property of the TreeView to get an array of TreeViewNodes.
From here, you just have to iterate over the array and use the Value property on the nodes to get what you want.
So, something like this should work,
TreeViewNodes[] selectedNodes = treeViewID.MultipleSelectedNodes;
ArrayList values = new ArrayList(selectedNodes.Count);
foreach (TreeViewNode node in selectedNodes) {
values.Add(node.Value);
}
And now you have selected node values ββin ArrayList.
a source to share