Last post Nov 21, 2008 12:32 PM by mfreeman
Nov 14, 2008 04:15 PM|mfreeman|LINK
I am developing an application that has an asp:Menu control that is populated from an asp:SiteMapDataSource control. I am using Dynamic Data for the CRUD screens for the lookup/code tables. I'd like to be able to have the Dynamic Data list pages integrated
into the menu. I could manually add them to my Web.sitemap file, but it would be even better if I could have Dynamic Data maintain those entries. Currently, I have Maintenance.aspx in the sitemap, and it is what a Dynamic Data project usually has as its
Default.aspx. I'd like to have the tables listed on that page integrated with my main menu control so that they appear in a submenu (DynamicMenu) under Maintenance. Is there a way to do this?
Nov 14, 2008 06:20 PM|sjnaughton|LINK
Yes there is a way, what you will have to do is load your SiteMapDataSource with the site.map file is you are using a file and then add the nodes to the submenu programatically.
Or you could generate the site map data programatically as below:
protected void Page_Load(object sender, EventArgs e)
//System.Collections.IList visibleTables = MetaModel.Default.VisibleTables;
System.Collections.IList visibleTables = MetaModel.Default.VisibleTables;
if (visibleTables.Count == 0)
throw new InvalidOperationException("There are no accessible tables...");
var root = new XElement("home");
foreach (var table in MetaModel.Default.VisibleTables)
XmlDataSource1.Data = root.ToString();
Menu1.DataSource = XmlDataSource1;
Menu1.Orientation = Orientation.Horizontal;
private XElement GetChildren(MetaTable parent)
XElement children =
new XAttribute("title", parent.DisplayName),
new XAttribute("url", parent.ListActionPath),
from c in parent.Columns
where c.GetType() == typeof(MetaChildrenColumn) &&
((MetaChildrenColumn)c).ChildTable.Name != parent.Name
This just creats a menu with each menu with each table as an entry in it and submenus are the children tables, but it should give you the idea of where to go from here.
Hope this helps [:D]
P.S. here'e the Menu and DataSource:
<StaticHoverStyle BackColor="#666666" ForeColor="White" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server" XPath="home/*"></asp:XmlDataSource>
Nov 21, 2008 12:32 PM|mfreeman|LINK
Sounds like a workable approach. I'll give it a try next week and let you know how it turns out.