I would like to get the second level from the current node the same way that you do in xslt. I can only get the Parent but I would like to always get the second level of the structure.
Should be able to do that with node.Children property. Be aware tho if you wish to iterate the child nodes of the current node, first assign the Children property to a new variable and then use foreach to iterate
var childNodes = nodeFactory.Node.GetCurrent().Children;
foreach (Node node in childNodes) {...}
Repeat Children property if you need to go two levels deep in the hierarchy.
Solved it by using simple If Else with .Parent. Not the bet way since it is not dynamic. Would be much easier if there was a currentNode.Path.level or something like that.
Hate to admit that XSLT is more useful in some regards ;)
Get level from currentnode in codebehind
I would like to get the second level from the current node the same way that you do in xslt. I can only get the Parent but I would like to always get the second level of the structure.
Hi froad,
Should be able to do that with node.Children property. Be aware tho if you wish to iterate the child nodes of the current node, first assign the Children property to a new variable and then use foreach to iterate
Repeat Children property if you need to go two levels deep in the hierarchy.
Hope this helps.
Regards,
/Dirk
But what if I am at third level or lower? How do I get the second level then?
Think there's two ways: either via Path property (comma separated list of node ids of parent nodes) or via .Parent property.
Hope this helps.
Regards,
/Dirk
Solved it by using simple If Else with .Parent. Not the bet way since it is not dynamic. Would be much easier if there was a currentNode.Path.level or something like that.
Hate to admit that XSLT is more useful in some regards ;)
Thanks for your time Dirk!
is working on a reply...