Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Find out the count of child elements of the current node View modes: 
User avatar
Member
Member
mxm_Stops - 2/22/2010 9:59:34 AM
   
Find out the count of child elements of the current node
Hello,

At the moment, I'm searching hours for a solution of the following problem:
I have a repeater over some documents in a page. Each document can have child-nodes of document type "file" (in my case a userdefined type, but should not differ).

Now in the repeater transformation, I need to know how many sub items (if there is any) are under the current node...

I just need a "Yes, there are subnodes" or "Now, there are no subnodes", just a simple bool ;)

Does anyone know a solution for me?

Thank you in Advance!!


Best regards and have a nice day,
Christoph

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 3/5/2010 2:09:04 PM
   
RE:Find out the count of child elements of the current node
Hi Christoph,

You can create custom function for transformation (please see Adding custom functions to transformations section from Dev.Guide for more details) and in this function you can call SelectNodes method (you can find sample code in Selecting nodes section) to get DataSet with all child nodes and then you can use .Rows.Count property of DataSet to get number of child nodes.

Best Regards,

Martin Dobsicek