Add new SiteMapNode to CurrentNode dynamically

Mar 31, 2010 at 9:22 AM


I can't seem to add a new node to the current sitemap node.

SiteMap.CurrentNode.ChildNodes.Add(new SiteMapNode(...));

The code runs ok but the node is not displayed in the breadcrumb trails.  Is there a way to be able to do this?

Thank you in advance.

Apr 28, 2010 at 10:12 PM

it seems that the ChildNodes property returns a copy of the actual collection.  fortunately, that property is read-write:

SiteMapNodeCollection childNodes = SiteMap.CurrentNode.ChildNodes;
childNodes.Add(new SiteMapNode(...));
SiteMap.CurrentNode.ChildNodes = childNodes;