Click here to Skip to main content
15,037,178 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I have a horizoatal menu with items( HR , PRODUCTION , QC )

now when i click on HR.. i want a vertical menu to be generated on the left side with HR related child items.......

Similarly, when i click on Production and QC, it should display its respective child items....

For this i have put two menu on master page.....Horizoantal menu populates from sitemap but how can i populate vertical menu based on the option i click...........

Thanks in advance......

1 solution

It would be fine if you post your code here. any way....
Here in this example i retrieve data from XML file, create a dataset then adding menu items to Menu Control.
<asp:menu id="MenuContent" runat="server" orientation="Vertical" cssclass="menustyle" xmlns:asp="#unknown">

protected void Page_Load(object sender, EventArgs e)
            if (!Page.IsPostBack)

        protected void EnableMenu()
            DataSet ds = new DataSet();
            DataRowView drPView;
            DataRowView drCView;
            DataView dvParent = new DataView(ds.Tables[0]);
            DataView dvChild = new DataView(ds.Tables[1]);
            MenuItem oParentMenuItem = new MenuItem();
            MenuItem oChildMenuItem = new MenuItem();

            for (int i = 0; i < dvParent.Count; i++)
                drPView = dvParent[i];
                oParentMenuItem = new MenuItem(drPView.Row.ItemArray["MenuCaption"].ToString(), drPView.Row.ItemArray["ParentId"].ToString());
                dvChild.RowFilter = "ParentId=" + drPView.Row.ItemArray["ParentId"].ToString();
                for (int i = 0; i &lt; dvChild.Count; i++)
                  drCView = dvChild[i];
                  oChildMenuItem  = new MenuItem(drCView.Row.ItemArray["MenuCaption"].ToString(), drCView.Row.ItemArray["ChildID"].ToString(), "", drCView.Row.ItemArray["MenuUrl"].ToString());

NOTE : Please change code based on your requirement. Mostly I typed coding in this textbox, so let me know if you have any doubt/issue.

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900