<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    多級下拉菜單(動態)


    -------------------------------------
    源代碼下載/Files/singlepine/topmenu.rar

    public class TopMenu : System.Web.UI.Page
    {
        protected DataRow[] father;
        protected DataRow[] first;
        protected DataRow[] second;
            private void Page_Load(object sender, System.EventArgs e)
            {
                
            }
        public static string ConnectionString=System.Configuration .ConfigurationSettings .AppSettings["ConnectionString"];
        
            GetDataSet#region GetDataSet
            public static DataSet GetDataSet(string sql)
            {
                SqlDataAdapter    sda =new SqlDataAdapter(sql,ConnectionString);
                DataSet ds=new DataSet();
                sda.Fill(ds);
                return ds;
            }
            #endregion
            Web Form Designer generated code#region Web Form Designer generated code
            override protected void OnInit(EventArgs e)
            {
                //
                // CODEGEN: This call is required by the ASP.NET Web Form Designer.
                //
                InitializeComponent();
                base.OnInit(e);
            }
            
            /**//**//**//// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {    
                this.Load += new System.EventHandler(this.Page_Load);
            }
            #endregion
        LoadTopMenu#region LoadTopMenu
        protected string LoadTopMenu()
        {
            //IsBoot設置菜單級別,0一級,1二級,2三級,依此類推.
            string sqlFather="select * from topmenu order by IsBoot";
            DataSet dsFather=GetDataSet(sqlFather);
            father=dsFather.Tables[0].Select("IsBoot=0","IsBoot");
            string menu="";            
            int one=0;
            int two=1;
            int three=1;
            foreach(DataRow drfather in father)
            {                
                menu+="mpmenu"+one+"=new mMenu("+"'"+drfather["text"]+"'"+",'/','self','','','','');";
                first=dsFather.Tables[0].Select("ParentID='"+Convert.ToInt32(drfather["ID"])+"' and IsBoot=1","IsBoot");
                foreach(DataRow drfirst in first)
                {
                    second=dsFather.Tables[0].Select("ParentID='"+Convert.ToInt32(drfirst["ID"])+"' and IsBoot=2","IsBoot");
                    if(second.Length==0)
                    {
                        menu+="mpmenu"+one+".addItem(new mMenuItem("+"'"+drfirst["text"]+"'";//description
                        menu+=","+"'"+drfirst["url"]+"'"+",";//url
                        menu+="'"+drfirst["target"]+"'"+",";//target
                        menu+=""+drfirst["visible"]+",";//是否可見,false可見,true不可見
                        menu+="'"+drfirst["status"]+"'"+",";//狀態條
                        menu+="null,'','','',''));";
                    }
                    foreach(DataRow drsecond in second)
                    {    
                        menu+="msub"+two+"=new mMenuItem("+"'"+drfirst["text"]+"','',"+"'"+drfirst["target"]+"'";
                        menu+=","+drfirst["visible"]+",";//是否可見,false可見,true不可見
                        menu+="'','1','','','','');";

                        menu+="msub"+three+".addsubItem(new mMenuItem("+"'"+drsecond["text"]+"'";//description
                        menu+=","+"'"+drsecond["url"]+"'"+",";//url
                        menu+="'"+drsecond["target"]+"'"+",";//target
                        menu+=""+drsecond["visible"]+",";//是否可見,false可見,true不可見
                        menu+="'"+drsecond["status"]+"'"+",";//狀態條
                        menu+="null,'','','',''));";
                        menu+="mpmenu"+one+".addItem(msub"+two+");";//addItem
                        three++;
                    }
                    two++;
                }
                one++;
            }
            return menu;
        }
        #endregion
    }

    3.數據庫腳本
     

    --建表
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[topmenu]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    drop table [dbo].[topmenu]
    GO

    CREATE TABLE [dbo].[topmenu] (
        [ID] [int] NOT NULL ,
        [parentId] [int] NOT NULL ,
        [text] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
        [url] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
        [target] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
        [IsBoot] [int] NULL ,
        [visible] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
        [status] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL 
    ) ON [PRIMARY]
    GO

    --插入測試數據
    insert into topmenu([ID],[parentId],[text],[url],[target],[IsBoot],[visible] ,[status])
    values(1,0,'深圳','http://singlepine.cnblogs.com/articles/259955.html','self',0,'false','深圳')

    insert into topmenu([ID],[parentId],[text],[url],[target],[IsBoot],[visible] ,[status])
    values(2,1,'南山','http://singlepine.cnblogs.com/articles/259955.html','self',1,'false','南山')

    insert into topmenu([ID],[parentId],[text],[url],[target],[IsBoot],[visible] ,[status])
    values(3,1,'福田','http://singlepine.cnblogs.com/articles/259955.html','self',1,'false','福田')

    insert into topmenu([ID],[parentId],[text],[url],[target],[IsBoot],[visible] ,[status])
    values(4,2,'科技園','http://singlepine.cnblogs.com/articles/259955.html','self',2,'false','科技園')

    insert into topmenu([ID],[parentId],[text],[url],[target],[IsBoot],[visible] ,[status])
    values(5,3,'塞格','http://singlepine.cnblogs.com/articles/259955.html','self',2,'false','塞格')

    insert into topmenu([ID],[parentId],[text],[url],[target],[IsBoot],[visible] ,[status])
    values(6,0,'廣州','http://singlepine.cnblogs.com/articles/259955.html','self',0,'false','廣州')

    insert into topmenu([ID],[parentId],[text],[url],[target],[IsBoot],[visible] ,[status])
    values(7,6,'廣州火車站','http://singlepine.cnblogs.com/articles/259955.html','self',1,'false','廣州火車站')

    posted on 2007-06-20 13:32 chenguo 閱讀(670) 評論(0)  編輯  收藏 所屬分類: 組件 標簽使用

    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    導航

    統計

    留言簿

    隨筆分類(1)

    文章分類(52)

    好友 小山的博客

    最新隨筆

    最新評論

    主站蜘蛛池模板: 女人张腿给男人桶视频免费版| 亚洲黄色免费观看| 亚洲色图在线观看| 日韩免费一区二区三区在线播放 | 国产精品亚洲а∨无码播放麻豆| 又大又黄又粗又爽的免费视频| 一进一出60分钟免费视频| 久久亚洲精品中文字幕| 国产又黄又爽又刺激的免费网址| 99精品免费视频| 亚洲中文无码永久免费| 中文字幕专区在线亚洲| 台湾一级毛片永久免费| 四虎成人精品国产永久免费无码 | 久久久久久亚洲精品中文字幕| 成年女人午夜毛片免费视频| 又黄又大的激情视频在线观看免费视频社区在线 | 免费成人午夜视频| 16女性下面扒开无遮挡免费| 美女视频黄频a免费观看| 亚洲精品亚洲人成在线观看麻豆| www.亚洲色图.com| 成年女人午夜毛片免费看| 日本中文字幕免费高清视频| 真正全免费视频a毛片| 久久精品国产亚洲AV香蕉| 亚洲一区二区三区国产精品| 最近中文字幕mv免费高清视频7 | 久久精品国产亚洲AV嫖农村妇女| 亚洲高清最新av网站| 在线观看特色大片免费视频| 免费网站观看WWW在线观看| 狠狠综合亚洲综合亚洲色| 亚洲国产激情在线一区| 亚洲V无码一区二区三区四区观看| 国产亚洲精品免费| 成人免费看片又大又黄| 免费人成在线观看69式小视频| 182tv免费视频在线观看| 一区二区视频在线免费观看| 在线观看亚洲免费视频|