public override SiteMapNodeCollection GetChildNodes(System.Web.SiteMapNode node)
{
PortalSiteMapNode portalNode = node as PortalSiteMapNode;
if (portalNode != null)
{
if (portalNode.Type == NodeTypes.Area)
{
SiteMapNodeCollection nodeColl = base.GetChildNodes(portalNode);
SPWeb currentWeb = SPContext.Current.Web;
SPListCollection lists = currentWeb.Lists;
PortalSiteMapNode rootNode = new PortalSiteMapNode(
portalNode.WebNode,
"listsNode",
NodeTypes.Heading,
"",
"Lists",
null);
nodeColl.Add(rootNode);
int i = 0;
foreach (SPList list in lists)
{
if (i > 10)
break;
i++;
string listUrl = list.DefaultViewUrl;
PortalSiteMapNode childNode = new PortalSiteMapNode(
rootNode.WebNode,
listUrl,
NodeTypes.Custom,
listUrl,
list.Title,
null);
rootNode.ChildNodes.Add(childNode);
}
return nodeColl;
}
else
{
return base.GetChildNodes(portalNode);
}
}
else
{
return new SiteMapNodeCollection();
}
}
note that in my code you dont need to dispose of the SPWeb object, since you are getting it from the context and if you dispose of it, it will not be availalble to other components on the page.