Database Menu Problems... Newbie

G

Guest

Hi,

I'm trying to create a menu programmatically, the same as shown in the code below built from a database. I’m using the skmMENU control and trying to build it into a CMS I’m creating. I have created a simple database with 2 tables, with a one to one relationship but I'm not sure if I'm going about this in the correct way! I’m really new to ASP.NET and would be very grateful for any advice.

tblContent
contentID
description
header
content


tblMenu
menuid
mnuName
mnuURL
mnuLevel
perantid

Can someone please give me some advice on how I do this! Some example would be really helpful! I found this on the internet which is very similar to what I want to do, but I’m just not sure how to implement it!

cmdLinks.Connection = cnDB
cmdLinks.CommandText = "dbo.spMenuItems"
cmdLinks.CommandType = CommandType.StoredProcedure
DataAdapter.Fill(ds, "MenuItems")

cmdBookmarks.Connection = cnDB
cmdBookmarks.CommandText = "dbo.spPortalDisplayBookmarks"
cmdBookmarks.CommandType = CommandType.StoredProcedure
cmdBookmarks.Parameters.Add("@ProfileNum", SqlDbType.int).Value = Session("ptl_ProfileNum")
DataAdapter2.Fill(ds2, "Bookmarks")

'Bookmark Administration Header
header = New MenuItem()
header.text = "Bookmarks"
PageMenu.Items.Add(header)

Dim y As Integer
For y = 0 To ds2.Tables("Bookmarks").Rows.Count - 1
'create subItem
subItem = New MenuItem()
'Add values to the subItem
subItem.Text = ds2.Tables("Bookmarks").Rows(y).Item("Name")
subItem.URL = ds2.Tables("Bookmarks").Rows(y).Item("URL")
'add the subItem to the "header"
header.SubItems.Add(subItem)

If ds2.Tables("Bookmarks").Rows(y).Item("ID") = 3 then
'Add another subItem to the subItem
subItem.LeftImage = "../images/Arrow.gif"
subItem.LeftImageAlign = ImageAlign.Right
SubItem2 = New MenuItem
subItem2.Text = ds2.Tables("Bookmarks").Rows(y).Item("Archive")
subItem2.URL = ds2.Tables("Bookmarks").Rows(y).Item("URL")
subItem.subItems.Add(SubItem2)
End If
Next y

'Links Header
header = New MenuItem()
header.text = "Links"
PageMenu.Items.Add(header)
Dim x As Integer
For x = 0 To ds.Tables("MenuItems").Rows.Count - 1
'create subItem
subItem = New MenuItem()
'Add values to the subItem
subItem.Text = ds.Tables("Menu").Rows(x).Item("Text")
subItem.URL = ds.Tables("Menu").Rows(x).Item("URL")
'add the subItem to the "header"
header.SubItems.Add(subItem)
Next x


Thanks!



...:: EXAMPLE MENU CODE WHICH NEEDS TO BE PRODUCED ::..
'Item 1
Dim submenu1 As New skmMenu.MenuItem("<img src=""images/menublip.gif"" align=""absmiddle"">Home", "")
'Sub Item 1
submenu1.SubItems.Add(New skmMenu.MenuItem("Sub Item 1", "page1.html"))
'Sub Item 2
Dim submenu3 As New skmMenu.MenuItem("Sub Item 2 ->", "")

'Sub Sub Item 2-1
submenu3.SubItems.Add(New skmMenu.MenuItem("Sub Item 2 - 1", "page1.html"))

'Sub Item 3
submenu1.SubItems.Add(submenu3)
submenu1.SubItems.Add(New skmMenu.MenuItem("Sub Item 3", "page2.html"))
Menu1.Items.Add(submenu1)

'Item 2
Dim submenu2 As New skmMenu.MenuItem("<img src=""images/menublip.gif"" align=""absmiddle"">Office", "")
'Sub Item 2
submenu2.SubItems.Add(New skmMenu.MenuItem("Sub Item 1", "page3.html"))
Menu1.Items.Add(submenu2)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top