use as follows
1 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
2 If Not IsPostBack Then
3 PopulateMenu()
4 End If
5
6 End Sub
7
8 Sub PopulateMenu()
9 Dim dst As System.Data.DataSet = GetMenuData()
10 For Each masterRow As System.Data.DataRow In dst.Tables("shopping_category").Rows()
11 Dim masterItem As New MenuItem(masterRow("category").ToString())
12 Menu1.Items.Add(masterItem)
13 For Each childRow As System.Data.DataRow In masterRow.GetChildRows("Children")
14 Dim childItem As New MenuItem(childRow("order_title").ToString())
15 masterItem.ChildItems.Add(childItem)
16 Next
17 Next
18 End Sub
19 Function GetMenuData() As System.Data.DataSet
20 Dim con As New System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.AppSettings("con"))
21 Dim dadCats As New _
22 System.Data.SqlClient.SqlDataAdapter("SELECT [category], primary_key FROM shopping_ca=", con)
23 Dim dadProducts As New _
24 System.Data.SqlClient.SqlDataAdapter("SELECT [category id], [primary_key], [order_title] FROM shopping_it", con)
25 Dim dst As New System.Data.DataSet()
26 dadCats.Fill(dst, "shopping_category")
27 dadProducts.Fill(dst, "shopping_items")
28 dst.Relations.Add("Children", _
29 dst.Tables("shopping_category").Columns("primary_key"), _
30 dst.Tables("shopping_items").Columns("Category ID"))
31 Return dst
32 End Function
This is the front end..
1 <asp:Menu
2 id="Menu1" Orientation="Vertical"
3 Runat="Server" staticdisplaylevels="2" StaticSubMenuIndent="0px" Width="180" >
4
5 <LevelMenuItemStyles>
6 <asp:MenuItemStyle CssClass="menuheader" ForeColor="#ff6603" />
7 <asp:MenuItemStyle cssclass="subheader" ForeColor="#0669ff" Font-Underline="true"/>
8 </LevelMenuItemStyles>
9 <StaticHoverStyle forecolor="#000000" />
10 <StaticSelectedStyle ForeColor="#000000" Font-Bold="true" Font-Underline="false" />
11 </asp:Menu>