tags:

views:

243

answers:

1

Hi, I'm trying to bind my own xml file (for some certain purposes i don't want to use a sitemap) to ASP.NET control. I have this code which - with help of some articles I have found - should bind ASP.NET Menu control to xml file, but it doesn't.

Do I miss something?

XmlDataSource xmlSource = new XmlDataSource();
xmlSource.DataFile = ResolveUrl("~/menu.xml");
xmlSource.XPath = @"/menu/Items/menuItem";
xmlSource.DataBind();

MenuItemBinding binding = new MenuItemBinding();
binding.DataMember = "menuItem";
binding.NavigateUrlField = "NavigateUrl";
binding.TextField = "Text";

Menu1.DataSource = xmlSource;
Menu1.DataBindings.Add(binding);
Menu1.DataBind();
A: 

Hi,

Parsing and filtering XML files with XPath is always difficult. Why you would not like to populate asp:Menu with Sitemaps??? I think SiteMaps are more flexible and easy to bind. Read this simple article: Asp:Menu With Sitemaps and let me know if you are convinced ?

Thank you

Awais