J
Julia B
Hi
I've got a menu control that I want to populate programmatically but I can't
work out how to add parent and child menuitems. I've found loads of examples
of how to do it using datasets and xml files, but I don't want to do that. I
want to do it in vb code. A very simple example of what I want is this:
Dim parentItem As MenuItem
Dim childItem As MenuItem
parentItem = New MenuItem("Home", "Home", "", "~/Home.aspx")
Me.MenuApplication.Items.Add(parentItem)
parentItem = New MenuItem("Help", "Help", "", "~/Help.aspx")
Me.MenuApplication.Items.Add(parentItem)
If Session("CurrentUserRole") = "4" Then
parentItem = New MenuItem("Admin", "Admin", "", "")
Me.MenuApplication.Items.Add(parentItem)
'### this is where the problem is - how to make this a
child item??
childItem = New MenuItem("Users", "Users", "", "~/Users.aspx")
Me.MenuApplication.Items.Add(childItem)
childItem = New MenuItem("Accounts", "Accounts", "",
"~/Accounts.aspx")
Me.MenuApplication.Items.Add(childItem)
End If
etc.
I've got a menu control that I want to populate programmatically but I can't
work out how to add parent and child menuitems. I've found loads of examples
of how to do it using datasets and xml files, but I don't want to do that. I
want to do it in vb code. A very simple example of what I want is this:
Dim parentItem As MenuItem
Dim childItem As MenuItem
parentItem = New MenuItem("Home", "Home", "", "~/Home.aspx")
Me.MenuApplication.Items.Add(parentItem)
parentItem = New MenuItem("Help", "Help", "", "~/Help.aspx")
Me.MenuApplication.Items.Add(parentItem)
If Session("CurrentUserRole") = "4" Then
parentItem = New MenuItem("Admin", "Admin", "", "")
Me.MenuApplication.Items.Add(parentItem)
'### this is where the problem is - how to make this a
child item??
childItem = New MenuItem("Users", "Users", "", "~/Users.aspx")
Me.MenuApplication.Items.Add(childItem)
childItem = New MenuItem("Accounts", "Accounts", "",
"~/Accounts.aspx")
Me.MenuApplication.Items.Add(childItem)
End If
etc.