i have an asp menu i am playing with and have it working with an xml file, but all ive read dont explain too well on pulling from a database. Are there any samples that you have found that will help?
I think im just stuck on how to setup and query the menu table to generate the expected format.
How would i best setup the table to allow for menu options depending on the user roles?
heres the working xml, i know i just change the xmldatasource to a sqldatasource, but again, how would i query the table to generate the submenus?
static xml file
I think im just stuck on how to setup and query the menu table to generate the expected format.
How would i best setup the table to allow for menu options depending on the user roles?
heres the working xml, i know i just change the xmldatasource to a sqldatasource, but again, how would i query the table to generate the submenus?
Code:
<asp:Menu ID="SiteMenu" runat="server" DataSourceID="XmlDataSource1" MaximumDynamicDisplayLevels="4"
StaticDisplayLevels="1" Orientation="Horizontal" CssClass="SiteMenu">
<DynamicHoverStyle CssClass="SiteMenuDynamicHover" />
<DynamicMenuItemStyle CssClass="SiteMenuDynamicItem" />
<DynamicMenuStyle CssClass="SiteMenuDynamic" />
<DataBindings>
<asp:MenuItemBinding DataMember="Menu" TextField="text" ValueField="text" NavigateUrlField="url" />
<asp:MenuItemBinding DataMember="SubMenu" TextField="text" ValueField="text" NavigateUrlField="url" />
</DataBindings>
</asp:Menu>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="App_Data/SiteMap.xml"
EnableCaching="false" XPath="/Home/Menu" />
static xml file
Code:
<Home>
<Menu text="PSR" url="#">
<Menu text="Safety Corner" url="#"></Menu>
<Menu text="Training" url="#"></Menu>
<Menu text="Integrity Programs" url="#">
<SubMenu text="CIP" url="#"></SubMenu>
<SubMenu text="SIP" url="#"></SubMenu>
</Menu>
<Menu text="Projects" url="projects"></Menu>
<Menu text="Admin" url="#">
<SubMenu text="Users" url="admin/users.aspx"></SubMenu>
</Menu>