Introduction
In this article, I am going to show how to easily generate menus using XML from the data source in Asp.net C#. By using this we can define the hierarchy separately in XML and use the same in the menus. Below is the real time code I have used in my project and I have attached the same in the attachment section.
Aspx page Code
- <asp:XmlDataSource ID="XmlDataSrc" runat="server" DataFile="App_Data/Tpms_Menus.xml" XPath="/menu/Admin/FirstlevelMenus"></asp:XmlDataSource>
- <asp:Menu ID="Menu1" runat="server" DataSourceID="XmlDataSrc" Orientation="Horizontal" OnMenuItemClick="Menu1_MenuItemClick" Font-Names="Verdana" ForeColor="White" Width="800px" CssClass="MYMenuClass">
- <DataBindings>
- <asp:MenuItemBinding DataMember="FirstlevelMenus" TextField="textdis" NavigateUrlField="urllink" />
- <asp:MenuItemBinding DataMember="secondlevelMenus" TextField="txtdis" NavigateUrlField="secondlevelurl" />
- <asp:MenuItemBinding DataMember="thirdlevelMenus" TextField="txtdis" NavigateUrlField="thirdlevelurl" />
- </DataBindings>
- </asp:Menu>


Prasanna MuraliPosted Jun 26, 2016, 9:01 AM
Nice share...