IE Treeview - Checking & Unchecking All Subnodes

P

Pat Roy

Hello...

I've created a treeview that looks something like:

Root
.....Folder1
.........Subfolder1A
.............File
.............File
.........Subfolder1B
.............File
.....Folder2
.........Subfolder2A
.............File
.........Subfolder2B
.............File
.............File

Each of the folders and files have the checkbox property turned on, so that everything but the root node has a checkbox. Now I need help with code the checks or uncheck all subfolders and files when a parent checkbox is checked or unchecked. Make sense?

So, for example, if the user checks Folder1's checkbox on, then all Folder1's subfolders and files need to have there checkboxes checked on.

I've been banging my head on this one and haven't figured anything out yet. Any help would be appreciated.
 
D

DotNetJunkies User

Not sure if you want C# or vb.net but the code (c#) I'm using is:

private void TreeView1_Check(object sender, Microsoft.Web.UI.WebControls.TreeViewClickEventArgs e){

TreeNode selectedNode =
TreeView1.GetNodeFromIndex(e.Node);

if (selectedNode.Nodes.Count>0){
foreach (TreeNode ChildNode in selectedNode.Nodes)
{ChildNode.Checked=selectedNode.Checked;}
}

}

If you want the vb code let me know and I'll translate.

Nicki
 
Joined
Mar 4, 2008
Messages
1
Reaction score
0
using js

Hay i want to do this action using JavaScript.
Actually the nodes are loaded form DB, and the click even is written in server side code, now when I click on a node the page reloads and even on fast speed it flickers a bit. So If any one can help me doing this task using JavaScript?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,183
Messages
2,570,965
Members
47,512
Latest member
FinleyNick

Latest Threads

Top