Home All Groups Group Topic Archive Search About
Author
17 Aug 2006 12:19 PM
varun kanwar
ok i tell u in detail.

database is:

menu_bar       option_no     menu_option
   1                     0                   a
   2                     1                   b
   3                     2                   c
   4                     2                   d
   5                     1                   e
   6                     1                   f
   7                     0                   g
   8                     7                   h
   9                     7                   i
   10                   9                   j
   11                   9                   k
   12                   7                   l


my coding is:

       Dim mainMenu1 As New MainMenu
       Dim menuItem As New MenuItem

       conn.Open()
       cmd.CommandText = "select * from user_profile where
option_no=0"
       cmd.Connection = conn
       dr = cmd.ExecuteReader
       While dr.Read
           menuItem.Text = Convert.ToString(dr(1))
           mainMenu1.MenuItems.Add(menuItem.Text)
       End While

       dr.Close()
       conn.Close()
       Menu = mainMenu1


and output should be:

   a                g
    |->b             |->h
    .    |->c        |->i
    .    |->d        .    |->j
    |->e             .    |->k
    |->f              |->l


this code adds "a" and "g" but i m unable to add rest of child and sub
child items.
i have shown u the database hope u can generate dynamic main menu from
there as output is required.

Author
17 Aug 2006 5:57 PM
tomb
You are only selecting 'a' and 'g' when you restrict your record
selection with "where option_no = 0".
Where are the sub-menus for 'a' and 'g' supposed to come from?

T

varun kanwar wrote:

Show quoteHide quote
>ok i tell u in detail.
>
>database is:
>
>menu_bar       option_no     menu_option
>   1                     0                   a
>   2                     1                   b
>   3                     2                   c
>   4                     2                   d
>   5                     1                   e
>   6                     1                   f
>   7                     0                   g
>   8                     7                   h
>   9                     7                   i
>   10                   9                   j
>   11                   9                   k
>   12                   7                   l
>
>
>my coding is:
>
>       Dim mainMenu1 As New MainMenu
>       Dim menuItem As New MenuItem
>
>       conn.Open()
>       cmd.CommandText = "select * from user_profile where
>option_no=0"
>       cmd.Connection = conn
>       dr = cmd.ExecuteReader
>       While dr.Read
>           menuItem.Text = Convert.ToString(dr(1))
>           mainMenu1.MenuItems.Add(menuItem.Text)
>       End While
>
>       dr.Close()
>       conn.Close()
>       Menu = mainMenu1
>
>
>and output should be:
>
>   a                g
>    |->b             |->h
>    .    |->c        |->i
>    .    |->d        .    |->j
>    |->e             .    |->k
>    |->f              |->l
>
>
>this code adds "a" and "g" but i m unable to add rest of child and sub
>child items.
>i have shown u the database hope u can generate dynamic main menu from
>there as output is required.
>

>
Author
18 Aug 2006 4:57 AM
varun kanwar
cmd.CommandText = "select * from user_profile"

ok llets change the command to this but even then how will i
distinguish between parent menu and child menu.

and big problem is where to right code to add child menu to parent menu.