Click here to Skip to main content
11,795,848 members (79,686 online)
Rate this: bad
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;
Posted 8-Nov-12 6:24am

1 solution

Rate this: bad
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.

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

  Print Answers RSS
0 Maciej Los 410
1 Abhinav S 368
2 OriginalGriff 300
3 Sergey Alexandrovich Kryukov 266
4 KrunalRohit 249
0 OriginalGriff 1,852
1 Maciej Los 1,465
2 KrunalRohit 1,300
3 CPallini 840
4 Richard MacCutchan 828

Advertise | Privacy | Mobile
Web04 | 2.8.151002.1 | Last Updated 12 Nov 2012
Copyright © CodeProject, 1999-2015
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