I am using ComponentArt Third party controls for ASP.NET 2.0. Here is the problem I am facing.
我正在使用ComponentArt第三方控件的ASP.NET 2.0。这是我面临的问题。
I created some ComponentArt.Web.UI.TreeView
at runtime on Page_Load
. Now at click event of a button, I want to get values of the selected nodes in the treeview.
我在Page_Load上运行时创建了一些ComponentArt.Web.UI.TreeView。现在,在按钮的单击事件中,我想获取树视图中所选节点的值。
Can someone help?
有人可以帮忙吗?
1 个解决方案
#1
Firstly I'm assuming you have MultipleSelectEnabled set to true to allow the selection of multiple nodes in the TreeView.
首先,我假设您已将MultipleSelectEnabled设置为true,以允许在TreeView中选择多个节点。
If you have that you can use the MultipleSelectedNodes property of the TreeView to get an array of TreeViewNodes.
如果你有,你可以使用TreeView的MultipleSelectedNodes属性来获取TreeViewNodes数组。
From here you just need to iterate through the array and use the Value property of the nodes to get what you need.
从这里你只需要迭代数组并使用节点的Value属性来获得你需要的东西。
So essentially 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 your selected node values in the ArrayList.
现在,您在ArrayList中拥有所选的节点值。
#1
Firstly I'm assuming you have MultipleSelectEnabled set to true to allow the selection of multiple nodes in the TreeView.
首先,我假设您已将MultipleSelectEnabled设置为true,以允许在TreeView中选择多个节点。
If you have that you can use the MultipleSelectedNodes property of the TreeView to get an array of TreeViewNodes.
如果你有,你可以使用TreeView的MultipleSelectedNodes属性来获取TreeViewNodes数组。
From here you just need to iterate through the array and use the Value property of the nodes to get what you need.
从这里你只需要迭代数组并使用节点的Value属性来获得你需要的东西。
So essentially 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 your selected node values in the ArrayList.
现在,您在ArrayList中拥有所选的节点值。