Database Menu Problem... Newbie

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Tim::.. (myatix_at_hotmail.com)
Date: 06/24/04


Date: Thu, 24 Jun 2004 02:03:02 -0700

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)



Relevant Pages

  • Database Menu Problems... Newbie
    ... 'Bookmark Administration Header ... subItem = New MenuItem() ... 'Links Header ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How should I create this menu
    ... header should change when a menuitem is selected. ... selecting menuitem #2 then display background color Green with background ... picture A, when menuitem2 is selected, then display background color ...
    (microsoft.public.dotnet.framework.aspnet)
  • How should I create this menu
    ... In the specifications it says that the background of the header ... should change when a menuitem is selected. ... For example when selecting ... menuitem #2 then display background color Green with background picture A, ...
    (microsoft.public.dotnet.framework.aspnet)