Click here to Skip to main content
14,920,094 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi my requirement is to display vertical menu ,
here is the code which i have done but it is in horizontal menu if i change orientation = vertical menu tab is not properly visible.
here is the code

//Site.Master

XML
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="_3tierapp.SiteMaster" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Database Driven Dynamic Control</title>
      <link href="CSS/TableTemplate.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:Menu ID="menuBar" runat="server" Orientation="Horizontal" Width="100%"
                CssClass="MenuBar" MaximumDynamicDisplayLevels="10">
                <StaticMenuStyle CssClass="StaticMenuItem" />
                <StaticMenuItemStyle CssClass="StaticMenuItemStyle" />
                <StaticHoverStyle CssClass="StaticHoverStyle" />
                <StaticSelectedStyle CssClass="StaticSelectedStyle" />
                <DynamicMenuItemStyle CssClass="DynamicMenuItemStyle" />
                <DynamicHoverStyle CssClass="DynamicHoverStyle" />
            </asp:Menu>
        </div>
        <div class="Container">
            <asp:ContentPlaceHolder ID="BodyContentPlaceHolder" runat="server">
            </asp:ContentPlaceHolder>
        </div>
    </form>
</body>
</html>


C#
protected void Page_Load(object sender, EventArgs e)
        {
            GetMenuData();
        }
        private void GetMenuData()
        {
            DataTable table = new DataTable();
            DataSet ds = new DataSet();
            string strCon = System.Configuration.ConfigurationManager.ConnectionStrings
            ["Employee"].ConnectionString;
            SqlConnection conn = new SqlConnection(strCon);
            string sql = "select menu_id, menu_name, menu_parent_id, menu_url from menuMaster";
            SqlCommand cmd = new SqlCommand(sql, conn);
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(table);

            DataView view = new DataView(table);
            view.RowFilter = "menu_parent_id is NULL";
            foreach (DataRowView row in view)
            {
                MenuItem menuItem = new MenuItem(row["menu_name"].ToString(),
                row["menu_id"].ToString());
                menuItem.NavigateUrl = row["menu_url"].ToString();
                menuBar.Items.Add(menuItem);
                AddChildItems(table, menuItem);
            }
        }
        private void AddChildItems(DataTable table, MenuItem menuItem)
        {
            DataView viewItem = new DataView(table);
            viewItem.RowFilter = "menu_parent_id=" + menuItem.Value;
            foreach (DataRowView childView in viewItem)
            {
                MenuItem childItem = new MenuItem(childView["menu_name"].ToString(),
                childView["menu_id"].ToString());
                childItem.NavigateUrl = childView["menu_url"].ToString();
                menuItem.ChildItems.Add(childItem);
                AddChildItems(table, childItem);
            }
        }
    }

Please suggest me to display the menu in vertical

Thanks in advance
Posted
Updated 19-Feb-15 17:23pm
v2

1 solution

hi King Fisher
i have not find the solution which you have posted on my question
   

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