I was building a breadcrumb trail for a site I was working on, and using the SiteMapPath control to render the breadcrumb. I wanted to hide the root node from the breadcrumb, but as the SiteMapControl gets its data directly from a SiteMapProvider rather than via a SiteMapDataSource, we cant use the SiteMapDataSource.ShowStartingNode property to hide the root node. I used this workaround:
Handle the SiteMapPath's ItemCreated event, where you can hide the root node:
//override the Page's OnInit protected override void OnInit(EventArgs e) { base.OnInit(e); Breadcrumb.ItemCreated += new SiteMapNodeItemEventHandler(Breadcrumb_ItemCreated); } void Breadcrumb_ItemCreated(object sender, SiteMapNodeItemEventArgs e) { //hide the root node, and it's following path separator if (e.Item.ItemIndex == 0 | (e.Item.ItemIndex ==1 && e.Item.ItemType ==SiteMapNodeItemType.PathSeparator)) { e.Item.Visible = false; } }
Powered by: newtelligence dasBlog 2.0.7226.0
© Copyright 2010, Sherwin Rice
E-mail