显示垂直菜单选项卡 [英] Display Vertical Menu Tab

查看:102
本文介绍了显示垂直菜单选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
我的要求是显示垂直菜单,

这里是我已经完成的代码但是如果我改变方向它在水平菜单中=垂直菜单选项卡不正确可见。

这里是代码



//Site.Master



 <%@       语言  =  C#    AutoEventWireup   =  true    CodeBehind   =  Site.master.cs   继承 < span class =code-keyword> =  _ 3tierapp.SiteMaster   %>  

< html xmlns = http://www.w3.org/1999/xhtml >
< head id = Head1 runat = server < span class =code-keyword>>
< title > 数据库驱动的动态控制< /标题 >
< link href = CSS / TableTemplate.css rel = 样式表 type = text / css / >
< asp:ContentPlaceHolder ID = head runat = 服务器 >
< / asp:ContentPlaceHolder >
< / head >
< body >
< 表格 id = form1 runat = server >
< div >
< asp:菜单 ID = menuBar runat = server Orientation = 水平 宽度 = 100%

CssClass = MenuBar MaximumDynamicDisplayLevels = 10 >
< StaticMenuStyle CssClass = StaticMenuItem / >
< StaticMenuItemStyle CssClass = StaticMenuItemStyle / >
< StaticHoverStyle CssClass = StaticHoverStyle / >
< StaticSelectedStyle CssClass = StaticSelectedStyle / >
< DynamicMenuItemStyle CssClass = DynamicMenuItemStyle / <跨度class =code-keyword>>
< DynamicHoverStyle < span class =code-attribute> CssClass = DynamicHoverStyle / > ;
< / asp:菜单 >
< / div >
< div class = 容器 >
< asp:ContentPlaceHolder < span class =code-attribute> ID = BodyContentPlaceHolder runat = 服务器 >
< / asp:ContentPlaceHolder >
< / div >
< < span class =code-leadattribute> / form >
< / body >
< / html >





  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
[ 雇员]的ConnectionString。
SqlConnection conn = new SqlConnection(strCon);
string sql = select menu_id,menu_name ,menu_parent_id,menu_url来自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为NULL;
foreach (DataRowView行视图中)
{
MenuItem menuItem = new MenuItem(行[ menu_name]。ToString(),
行[ menu_id]。ToString()) ;
menuItem.NavigateUrl = row [ menu_url]。ToString();
menuBar.Items.Add(menuItem);
AddChildItems(table,menuItem);
}
}
私有 void AddChildItems(DataTable表,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);
}
}
}



请建议我垂直显示菜单



先谢谢

解决方案

嗨King Fisher

i找不到您在我的问题上发布的解决方案

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

<%@ 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>



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

解决方案

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


这篇关于显示垂直菜单选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆