Your code is fine. If it's not working then the page you are on doesn't have any children or they're not published. But fundamentally what you are doing is exactly right.
@Mr A - all nodes, i.e. i'm creating a list of categories and a list of its products so image a nested repeater, outer loop iterates over the categories and for each category iterate over the products. thanks.
@Dan - ok i'm not perfect :) so i'll check again. thanks.
nested foreach
I'm trying to create a nested foreach to iterate over the parent and then the children.
Obviously this isn't working because @cat.Children is null. Any ideas how i can do this?
Thanks.
Do you want to show all the nodes including children and their parents or you are looking for specific nodes??
Your code is fine. If it's not working then the page you are on doesn't have any children or they're not published. But fundamentally what you are doing is exactly right.
@Mr A - all nodes, i.e. i'm creating a list of categories and a list of its products so image a nested repeater, outer loop iterates over the categories and for each category iterate over the products. thanks.
@Dan - ok i'm not perfect :) so i'll check again. thanks.
if you get an null-error maybe some of the cats don't have a child? You could try a null-check?
if(cat.Children != null)
Strange, all nodes are defo published however i republished entire tree then it started working.
is working on a reply...