Click here to Skip to main content
13,050,764 members (85,757 online)
Rate this:
Please Sign up or sign in to vote.
See more:

i am using the Menu in with c#. both the menu and sub menu come from the table. at present the sub menu display horizontally but i want to show under the its menu or on mouse over effect of that menu....

please help me and how this will be achieved.....

i want to set the menu like...

Menu1 >> menu2 >>  menu3 >> menu4
mnu1     mnu2      mnu3
but it display like 
Menu1 >> menu2 >> menu3 >> menu4
when i click on menu1 it display like,,,
Menu1>>mnu1 mnu2
this what i not want , i want display sub menu vertically as a sub menu of its main menu....

i use the code like...

 if (!IsPostBack)
                string menu_string = "select distinct category from ctgry";
                SqlDataAdapter menu_ad = new SqlDataAdapter(menu_string, c.getcon());
                DataSet ds_menu = new DataSet();
                for (int i = 0; i < ds_menu.Tables[0].Rows.Count; i++)
                    MenuItem mnu = new MenuItem();
                    mnu.Text = ds_menu.Tables[0].Rows[i][0].ToString();
                    string s1 = "select subctgry from subctgry where category='" + ds_menu.Tables[0].Rows[i][0].ToString() + "'";
                    SqlDataAdapter ad_sub_menu = new SqlDataAdapter(s1, c.getcon());
                    DataSet ds_sub_menu = new DataSet();
                    if (ds_sub_menu.Tables[0].Rows.Count != 0)
                        for (int j = 0; j < ds_sub_menu.Tables[0].Rows.Count; j++)
                            MenuItem sub_menu = new MenuItem();
                            sub_menu.Value = ds_menu.Tables[0].Rows[i][0].ToString();
                            sub_menu.Text = ds_sub_menu.Tables[0].Rows[j][0].ToString();

<asp:Menu ID="Menu1" runat="server" Font-Size="Small" ForeColor="Black" 
                   Orientation="Horizontal" Height="23px" PathSeparator="/">
                   <staticmenuitemstyle itemspacing="2px" />
                   <dynamicmenuitemstyle font-size="Medium" forecolor="#FF0066" />
Posted 4-Aug-12 0:11am
Updated 6-Aug-12 20:27pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Please follow the link for exactly as per your requirement[^]

Mits Machhi 7-Aug-12 2:40am
dear Ashish, i have already tried that link but not success.. please give suggestion or help furtherrr
AshishChaudha 7-Aug-12 2:47am
Mitesh, I tried that solution for one of my project and its working fine. First follow as it is code of that solution then do RND as per your requirement. OR I can mail you the code.
Mits Machhi 7-Aug-12 3:01am
<span>please tell me first my code for getting menu and its submenu is right or may be some changes....
if you mail the code to me so , so it greatful to me...
mail </span>
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

the portion "...but i want to show under the its menu or on mouse over effect.." needs more clarification.
However see if Dynamically populating menu items from the database in ASP.NET[^] can help you..
Mits Machhi 6-Aug-12 2:05am
when user move the mouse over the main menu which text come from the table so its submenu as its main menuuu

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 7 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100