Building Menu from DB

Discussion in 'ASP .Net' started by =?Utf-8?B?VGltOjouLg==?=, Jun 8, 2004.

  1. Hi can someone please tell me how I dynamically create a menu like the one shown below from a database. I want to create a loop that loops through all the records in a table and builds a table similar to the menu shown below

    I would be grateful if you could give me a ny assistance with this

    Thanks

    ...:: CODE ::.

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loa
    'Put user code to initialize the page her
    If (Page.IsPostBack = False) The
    Dim submenu1 As New skmMenu.MenuItem("<img src=""images/menublip.gif"" align=""absmiddle"">Home", ""

    submenu1.SubItems.Add(New skmMenu.MenuItem("Sub Item 1", "page1.html")
    submenu1.SubItems.Add(New skmMenu.MenuItem("Sub Item 2", "page2.html")

    Dim submenu3 As New skmMenu.MenuItem("Sub Item 3 ->", ""
    submenu3.SubItems.Add(New skmMenu.MenuItem("Sub Item 3 - 1", "page1.html")
    submenu3.SubItems.Add(New skmMenu.MenuItem("Sub Item 3 - 2", "page2.html")

    submenu1.SubItems.Add(submenu3
    submenu1.SubItems.Add(New skmMenu.MenuItem("Sub Item 4", "page4.html")
    submenu1.SubItems.Add(New skmMenu.MenuItem("Sub Item 5", "page5.html")
    submenu1.SubItems.Add(New skmMenu.MenuItem("Sub Item 6", "page6.html")
    Menu1.Items.Add(submenu1

    Dim submenu2 As New skmMenu.MenuItem("<img src=""images/menublip.gif"" align=""absmiddle"">Office", ""

    submenu2.SubItems.Add(New skmMenu.MenuItem("Sub Item 1", "page3.html", "tooltip1")
    submenu2.SubItems.Add(New skmMenu.MenuItem("Sub Item 2", "page4.html", "tooltip2")
    Menu1.Items.Add(submenu2

    Menu1.CssClass = "menustyle
    Menu1.DefaultCssClass = "menuitem
    Menu1.DefaultMouseOverCssClass = "mouseover

    Menu1.HighlightTopMenu = Tru
    Menu1.Opacity = 7
    Menu1.zIndex = 10
    End I
    End Sub
    =?Utf-8?B?VGltOjouLg==?=, Jun 8, 2004
    #1
    1. Advertising

  2. The easiest way to produce a side menu from a database is to pull the
    information from a database and bind to a DataGrid with a hyperlink column
    (this can also be accomplished through a DataList or Repeater, with a bit
    more work).

    For a hierarchical menu, you can either use related DataTables in a DataSet
    or pull the data as XML. You can download a free treeview control from
    www.asp.net in the Internet Explorer Web Controls:
    http://www.asp.net/IEWebControls/Download.aspx?tabindex=0&tabid=1

    There are articles on how to use this control on the Microsoft MSDN site.
    http://msdn.microsoft.com/library/default.asp?url=/workshop/webcontrols/overview/treeview.asp

    These controls are not supported by Microsoft, but you will download the
    full source, so you can work through any bugs yourself.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    ************************************************
    Think Outside the Box!
    ************************************************
    "Tim::.." <> wrote in message
    news:D...
    > Hi can someone please tell me how I dynamically create a menu like the one

    shown below from a database. I want to create a loop that loops through all
    the records in a table and builds a table similar to the menu shown below!
    >
    > I would be grateful if you could give me a ny assistance with this!
    >
    > Thanks.
    >
    > ..:: CODE ::..
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As

    System.EventArgs) Handles MyBase.Load
    > 'Put user code to initialize the page here
    > If (Page.IsPostBack = False) Then
    > Dim submenu1 As New skmMenu.MenuItem("<img

    src=""images/menublip.gif"" align=""absmiddle"">Home", "")
    >
    > submenu1.SubItems.Add(New skmMenu.MenuItem("Sub Item 1",

    "page1.html"))
    > submenu1.SubItems.Add(New skmMenu.MenuItem("Sub Item 2",

    "page2.html"))
    >
    > Dim submenu3 As New skmMenu.MenuItem("Sub Item 3 ->", "")
    > submenu3.SubItems.Add(New skmMenu.MenuItem("Sub Item 3 - 1",

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

    "page2.html"))
    >
    > submenu1.SubItems.Add(submenu3)
    > submenu1.SubItems.Add(New skmMenu.MenuItem("Sub Item 4",

    "page4.html"))
    > submenu1.SubItems.Add(New skmMenu.MenuItem("Sub Item 5",

    "page5.html"))
    > submenu1.SubItems.Add(New skmMenu.MenuItem("Sub Item 6",

    "page6.html"))
    > Menu1.Items.Add(submenu1)
    >
    > Dim submenu2 As New skmMenu.MenuItem("<img

    src=""images/menublip.gif"" align=""absmiddle"">Office", "")
    >
    > submenu2.SubItems.Add(New skmMenu.MenuItem("Sub Item 1",

    "page3.html", "tooltip1"))
    > submenu2.SubItems.Add(New skmMenu.MenuItem("Sub Item 2",

    "page4.html", "tooltip2"))
    > Menu1.Items.Add(submenu2)
    >
    > Menu1.CssClass = "menustyle"
    > Menu1.DefaultCssClass = "menuitem"
    > Menu1.DefaultMouseOverCssClass = "mouseover"
    >
    > Menu1.HighlightTopMenu = True
    > Menu1.Opacity = 75
    > Menu1.zIndex = 100
    > End If
    > End Sub
    Cowboy \(Gregory A. Beamer\) [MVP], Jun 8, 2004
    #2
    1. Advertising

  3. =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=, Jun 8, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2hlbQ==?=

    Building the menu Control Programatically

    =?Utf-8?B?U2hlbQ==?=, Jan 23, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    356
    =?Utf-8?B?U2hlbQ==?=
    Jan 23, 2006
  2. Midex
    Replies:
    24
    Views:
    877
  3. madhur
    Replies:
    0
    Views:
    385
    madhur
    May 20, 2007
  4. Lawrence D'Oliveiro

    Building The Android Options Menu

    Lawrence D'Oliveiro, May 13, 2011, in forum: Java
    Replies:
    0
    Views:
    530
    Lawrence D'Oliveiro
    May 13, 2011
  5. Derk

    Building a menu 'on the fly'

    Derk, Apr 30, 2004, in forum: ASP General
    Replies:
    2
    Views:
    83
    John Blessing
    May 1, 2004
Loading...

Share This Page