SiteMapDataSource1.Provider = SiteMap.Providers["left"]; //这里实际上提示我们可以编程实现
如何设计时实现呢?
假设我们站点下有2个sitemap文件:web.sitemap , left.sitemap
在web.config里如下设定: <siteMap defaultProvider="XmlSiteMapProvider" enabled="true"> <providers> <add name="XmlSiteMapProvider" description="SiteMap provider which reads in .sitemap XML files." type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" siteMapFile="web.sitemap" securityTrimmingEnabled="true"/> <add name="left" description="SiteMap provider which reads in .sitemap XML files." type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" siteMapFile="left.sitemap" securityTrimmingEnabled="true"/> </providers> </siteMap>
设计时,在SiteMapDataSource1属性窗口的SiteMapProvider 里填 left 即可