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


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

<html xmlns="">
<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">
    <form id="form1" runat="server">
            <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" />
        <div class="Container">
            <asp:ContentPlaceHolder ID="BodyContentPlaceHolder" runat="server">

protected void Page_Load(object sender, EventArgs e)
        private void GetMenuData()
            DataTable table = new DataTable();
            DataSet ds = new DataSet();
            string strCon = System.Configuration.ConfigurationManager.ConnectionStrings
            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);


            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(),
                menuItem.NavigateUrl = row["menu_url"].ToString();
                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(),
                childItem.NavigateUrl = childView["menu_url"].ToString();
                AddChildItems(table, childItem);

Please suggest me to display the menu in vertical

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

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