kentico_martind2 wrote: In the Kentico CMS API Documentation you can look for TreeNodeCollection Class where you can find the methods usable with this class... there is method called "GetItem(Int32)" - Gets the item on the specified index.
Although this method is listed in the API Documentation, it does not exist in the API itself.
Look in the CMS.TreeEngiine.TreeNodeCollection class (the actual class in Visual Studio, not the API Documentation) - there is no GetItem() method.
kentico_martind2 wrote: I don't know what exactly is your goal but you can also use
TreeProvider and
SelectSingleNode method, see examples in the DevGuide:
Managing documents
I want to select the first child node under the current node, but I do not know (or care) what node ID is.
So, this should work:
CMS.TreeEngine.TreeNode child = CMSContext.CurrentDocument.Children.OrderBy(c => c.NodeLevel).FirstOrDefault();
But it doesn't. I get the following error:
"Unable to cast object of type 'CMS.TreeEngine.TreeNodeCollection' to type 'CMS.TreeEngine.TreeNode'."
FirstOrDefault() should return a single object class (TreeNode) of TreeNodeCollection, but it looks like it is returning TreeNodeCollection instead.
It looks like TreeNodeCollection does not properly implement generic collections, so standard LINQ comands will not work properly with it.
How can I perform the equivalent of the code above?