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

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

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

    多級下拉菜單(動態(tài))


    -------------------------------------
    源代碼下載/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"]+"'"+",";//狀態(tài)條
                        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"]+"'"+",";//狀態(tài)條
                        menu+="null,'','','',''));";
                        menu+="mpmenu"+one+".addItem(msub"+two+");";//addItem
                        three++;
                    }
                    two++;
                }
                one++;
            }
            return menu;
        }
        #endregion
    }

    3.數(shù)據庫腳本
     

    --建表
    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

    --插入測試數(shù)據
    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 閱讀(680) 評論(0)  編輯  收藏 所屬分類: 組件 標簽使用

    <2025年7月>
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    導航

    統(tǒng)計

    留言簿

    隨筆分類(1)

    文章分類(52)

    好友 小山的博客

    最新隨筆

    最新評論

    主站蜘蛛池模板: 国产亚洲美女精品久久久2020| 性生交片免费无码看人| 亚洲AV无码一区二区三区国产 | 香蕉97超级碰碰碰免费公| 亚洲av色福利天堂| 国产日韩AV免费无码一区二区| 亚洲综合无码无在线观看| 日韩精品久久久久久免费| 亚洲av网址在线观看| 特级精品毛片免费观看| 久久亚洲精品无码VA大香大香| 91免费福利精品国产| 亚洲婷婷综合色高清在线| 成年轻人网站色免费看| 亚洲hairy多毛pics大全| 四虎免费影院4hu永久免费| 青青草97国产精品免费观看| 亚洲一本大道无码av天堂| 91精品成人免费国产| 亚洲丝袜美腿视频| 在线天堂免费观看.WWW| 国内成人精品亚洲日本语音| 亚洲国产综合无码一区二区二三区| 久久嫩草影院免费看夜色| 亚洲国产天堂在线观看| 成人网站免费观看| 人与动性xxxxx免费| 亚洲国产一区二区三区青草影视| 免费AA片少妇人AA片直播| 久久亚洲精品无码gv| 亚洲中文字幕无码一区二区三区| 小日子的在线观看免费| 亚洲综合国产成人丁香五月激情 | 久久久无码精品亚洲日韩软件| 免费萌白酱国产一区二区三区| 亚洲人成网站在线播放影院在线| 中文字幕无码成人免费视频| 国产V片在线播放免费无码| 亚洲日本在线观看网址| vvvv99日韩精品亚洲| 最近中文字幕免费2019|