ASPX templates
Version 3.x > ASPX templates > What is the best practice for getting the child nodes of a document? View modes: 
User avatar
Certified Developer 9
Certified Developer 9
jkh80 - 2/25/2009 5:57:15 PM
   
What is the best practice for getting the child nodes of a document?
I'm having some trouble getting the child nodes for a document. After I have created a TreeNode object representing the document that I want to get the child documents for, what do I do next?

int parentId =22;

CMS.TreeEngine.TreeNode parent =
CMS.CMSHelper.TreeHelper.SelectSingleDocument(parentId);

I see that the TreeNode object has a NodeChildNodesCount property for getting the number of child nodes, but I'm a little lost besides that, as I'm extremely new to Kentico. Any help would be appreciated.

Also, please excuse my ignorance if this is in the documentation somewhere.

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 3/3/2009 6:18:32 AM
   
RE:What is the best practice for getting the child nodes of a document?
Hello,

You can use following sample code to get all nodes under parent node:

DataSet ds = tree.SelectNodes("SiteName", parent.NodeAliasPath + "/%", "en-us", false);

Best Regards,

Martin Dobsicek