Click here to Skip to main content
15,889,096 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a function where I get the parent and the childnode and i want each time the user clicked on the sitemap wich is composed by the following code:
C#
Label_fatdata.Text += "<a id="fatdata" style="removed:pointer; margin-removed0px; text-transform:uppercase; font-size:10px; font-weight:500;" önclick="\"click(TreeView1," snode="" mode="hold" />


i want that redraws the main tree with the node (parent + child) that he gets from the backup tree. But so far I am having a lot of problems...first in if clause i need to verify the element 'a' with the backup tree.
C#
void click(TreeView one, TreeView two)
        {
            if (one.SelectedNode.ValuePath == two.SelectedNode.ValuePath)
            {
                TreeNode parentdata = two.SelectedNode.Parent;
                TreeNodeCollection childdata = two.SelectedNode.ChildNodes;

                one.Nodes.Add(parentdata);
                one.Nodes[0].ChildNodes.Add(childdata[0]);
                one.Nodes.Clear();
                one.DataBind();
            }
        }
Posted
v2

1 solution

Instead of comparing the trees like in your code, an easier approach would be to :

1. Save the value the user selects to a session or viewstate variable

2. When redrawing the tree, add If condition to do what you want with the parent child nodes if the value of the node being redrawn = the saved variable. You can do this in the TreeView.TreeNodeDataBound event. simple.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900