User-330204900 posted
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)
{
root.Add(GetChildren(table));
}
XmlDataSource1.Data = root.ToString();
Menu1.DataSource = XmlDataSource1;
Menu1.Orientation = Orientation.Horizontal;
Menu1.DataBind();
}
private XElement GetChildren(MetaTable parent)
{
XElement children =
new XElement("Menu",
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
orderby c.DisplayName
select GetChildren(((MetaChildrenColumn)c).ChildTable));
return children;
}
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:
<asp:Menu
ID="Menu1"
runat="server"
Orientation="Horizontal"
StaticEnableDefaultPopOutImage="False" MaximumDynamicDisplayLevels="5">
<DataBindings>
<asp:MenuItemBinding
DataMember="Menu"
TextField="title"
NavigateUrlField="url" />
</DataBindings>
<StaticHoverStyle BackColor="#666666" ForeColor="White" />
</asp:Menu>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" XPath="home/*"></asp:XmlDataSource>