Using Asp:menu and XmlDataSource

I’ve started to use  Asp:menu with XmlDataSource based on Quick Start Example.

To show many top level elements I tried to specify XPath, but failed to do it correctly(probably due to missing XML namespace).
So I changed the XML schema aa suggested in Asp.Net Menu Control Binding with XMLDataSource  and used XPath=”/Home/Menu” to not show single root Item.

Unfortunately DataBinding doesn’t support default properties in XML file.All nodes must have all attributes, specified in DataBinding  section.
Otherwise InvalidOperationException like the following will be shown:
Could not bind to the ‘Selectable’ property (specified by SelectableField) while databinding Menu. Please check the Bindings fields. 

It was a requirement to show top left menu item differently than other top menu.I was able conditionally specify first node of a few siblings using “Home/menu[1]|” Then I was about to use Templates and follow approach from Customise Individual Menu Items article .But suddenly I understood, that it is simpler to have left top menu as one control and other menus as second control with diferent behavior -KISS.

Advertisements