<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設(shè)置菜單級別,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ù)據(jù)庫腳本
     

    --建表
    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ù)據(jù)
    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)  編輯  收藏 所屬分類: 組件 標(biāo)簽使用

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

    導(dǎo)航

    統(tǒng)計(jì)

    留言簿

    隨筆分類(1)

    文章分類(52)

    好友 小山的博客

    最新隨筆

    最新評論

    主站蜘蛛池模板: 亚洲av无码一区二区三区不卡| 免费91麻豆精品国产自产在线观看| 亚洲a在线视频视频| 日本免费观看网站| 免费看片在线观看| 国产免费无码一区二区| 特级aaaaaaaaa毛片免费视频| 亚洲AV一二三区成人影片| 亚洲成AV人片在线观看无码| 亚洲成a人片在线播放| 日本一道本高清免费| 99久久综合国产精品免费| 久久午夜免费鲁丝片| 女同免费毛片在线播放| 特级毛片aaaa免费观看| 男男gay做爽爽的视频免费| 在线精品亚洲一区二区 | 四虎国产精品成人免费久久| 67194在线午夜亚洲| 亚洲福利视频一区二区三区| 亚洲av成人无码久久精品| 亚洲精品无码av人在线观看 | 亚洲成AV人片久久| 久久亚洲精精品中文字幕| 亚洲国产精华液网站w| 亚洲中久无码不卡永久在线观看| 免费一级毛片免费播放| 日日操夜夜操免费视频| 免费看无码自慰一区二区| 歪歪漫画在线观看官网免费阅读| 亚洲精品视频免费看| 久热中文字幕在线精品免费| 91禁漫免费进入| 久久精品免费一区二区| 亚洲一级毛片免费看| 国产精品色拉拉免费看| 国产精品爱啪在线线免费观看| 2022久久国产精品免费热麻豆| 久久国产乱子伦免费精品| 色影音免费色资源| 国产精品无码免费播放|