Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET Treeview
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:
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.
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 8-Nov-12 6:24am
hh_7643
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 354
1 Richard MacCutchan 320
2 OriginalGriff 255
3 Vinay Mistry 168
4 Jared Sanow 145
0 Sergey Alexandrovich Kryukov 5,939
1 OriginalGriff 4,885
2 CPallini 2,473
3 Abhinav S 1,507
4 Richard MacCutchan 1,437


Advertise | Privacy | Mobile
Web04 | 2.8.140814.1 | Last Updated 12 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100