View Single Post
  #2 (permalink)  
Old 07-23-2007, 11:28 PM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Default Re: How to Populate menu using sitemap and asp .net menu control and c#:

Depending on your requirements you can populate the tree view control using different sources.

Here I give the example for populating the asp .net menu using sitemap.
private void CreateMenuControl()
{

Menu1.DataSource = GetSiteMapDataSource();
Menu1.DataBind();

}

private SiteMapDataSource GetSiteMapDataSource()
{
XmlSiteMapProvider xmlSiteMap = new XmlSiteMapProvider();
System.Collections.Specialized.NameValueCollection myCollection = new System.Collections.Specialized.NameValueCollection (1);
myCollection.Add("siteMapFile", "Web.sitemap");
xmlSiteMap.Initialize("provider", myCollection);
xmlSiteMap.BuildSiteMap();

SiteMapDataSource siteMap = new SiteMapDataSource();

return siteMap;
}
Reply With Quote