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;
} |