|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
dynamic main menudatabase 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 this code adds "a" and "g" but i m unable to add rest of child and sub|->f |->l child items. i have shown u the database hope u can generate dynamic main menu from there as output is required. 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. > > > 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. |
|||||||||||||||||||||||