<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        asp.net DropDownList 三級聯動下拉菜單實現代碼

        來源:懂視網 責編:小采 時間:2020-11-27 22:43:43
        文檔

        asp.net DropDownList 三級聯動下拉菜單實現代碼

        asp.net DropDownList 三級聯動下拉菜單實現代碼: 代碼如下:if (!IsPostBack) { //一級分類列表 this.DropDownList1.DataSource = dsbb.SelectSubjct1(); this.DropDownList1.DataTextField = cName; this.DropDownList1.DataValueField = Ccode
        推薦度:
        導讀asp.net DropDownList 三級聯動下拉菜單實現代碼: 代碼如下:if (!IsPostBack) { //一級分類列表 this.DropDownList1.DataSource = dsbb.SelectSubjct1(); this.DropDownList1.DataTextField = cName; this.DropDownList1.DataValueField = Ccode

        代碼如下:

        if (!IsPostBack)
        {
        //一級分類列表
        this.DropDownList1.DataSource = dsbb.SelectSubjct1();
        this.DropDownList1.DataTextField = "cName";
        this.DropDownList1.DataValueField = "Ccode";
        this.DropDownList1.DataBind();
        this.DropDownList1.Items.Insert(0,new ListItem("請選擇一級分類","0"));
        this.DropDownList8.Items.Insert(0, new ListItem("請選擇二級分類", "0"));
        this.DropDownList9.Items.Insert(0,new ListItem ("請選擇三級分類","0"));
        //二級分類列表

        }
        /// <summary>
        /// 綁定二級分類
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
        libs.Database.Dbbase dbb = new libs.Database.Dbbase();
        if (Convert.ToInt32(this.DropDownList1.SelectedValue) == 0) //清除列表內容
        {
        this.DropDownList8.Items.Clear();
        this.DropDownList8.Items.Insert(0, new ListItem("請選擇二級分類", "0"));
        this.DropDownList9.Items.Clear();
        this.DropDownList9.Items.Insert(0, new ListItem("請選擇三級分類", "0"));
        }
        else //二級分類列表
        {
        this.DropDownList8.DataSource = dbb.Selectsubjct2(this.DropDownList1.SelectedValue.Substring(0,2));
        this.DropDownList8.DataTextField = "cName";
        this.DropDownList8.DataValueField = "Ccode";
        this.DropDownList8.DataBind();
        this.DropDownList8.Items.Insert(0,new ListItem ("請選擇二級分類","0"));
        this.DropDownList9.Items.Clear();//清除第三分類
        this.DropDownList9.Items.Insert(0, new ListItem("請選擇三級分類", "0"));
        }
        }
        /// <summary>
        /// 綁定三級分類
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DropDownList8_SelectedIndexChanged(object sender, EventArgs e)
        {
        libs.Database.Dbbase dbase = new libs.Database.Dbbase();
        this.DropDownList9.DataSource = dbase.selectsubject3(this.DropDownList8.SelectedValue.Substring(0,4));
        this.DropDownList9.DataTextField = "cName";
        this.DropDownList9.DataValueField = "Ccode";
        this.DropDownList9.DataBind();
        this.DropDownList9.Items.Insert(0,new ListItem("請選擇三級分類","0"));
        }

        Dbbase.cs頁:
        代碼如下:


        /// <summary>
        /// 查詢一級欄目
        /// </summary>
        /// <returns></returns>
        public DataSet SelectSubjct1()
        {
        string con = System.Configuration.ConfigurationSettings.AppSettings["sqlconn"];
        SqlConnection conn = new SqlConnection(con);
        string sqlstr = "SELECT kndid, Ccode, cName, cLevel FROM kind WHERE cLevel = 1";
        DataSet dst = new DataSet();
        SqlDataAdapter sda = new SqlDataAdapter(sqlstr,conn);
        try
        {
        sda.Fill(dst);
        return dst;
        }
        catch (Exception ex)
        {
        throw new Exception(ex.Message);
        }
        finally
        {
        conn.Close();
        }
        }
        /// <summary>
        /// 查詢二級欄目內容
        /// </summary>
        /// <param name="ccode"></param>
        /// <returns></returns>
        public DataSet Selectsubjct2(string ccode)
        {
        string conn1 = System.Configuration.ConfigurationSettings.AppSettings["sqlconn"];
        SqlConnection conn = new SqlConnection(conn1);
        string sqqq = "select kndid,Ccode,cName,cLevel from kind where cLevel = 2 and Ccode like '" + ccode + "%'";
        DataSet dss = new DataSet();
        SqlDataAdapter sdd = new SqlDataAdapter(sqqq,conn);
        try
        {
        sdd.Fill(dss);
        return dss;
        }
        catch (Exception ex)
        {
        throw new Exception(ex.Message);
        }
        finally
        {
        conn.Close();
        }
        }
        /// <summary>
        /// 查詢三級欄目內容
        /// </summary>
        /// <param name="cde"></param>
        /// <returns></returns>
        public DataSet selectsubject3(string cde)
        {
        string conn2 = System.Configuration.ConfigurationSettings.AppSettings["sqlconn"];
        SqlConnection conn = new SqlConnection(conn2);
        string sqq = "select kndid,Ccode,cName,cLevel from kind where cLevel = 3 and Ccode like '" + cde + "%'";
        DataSet dst = new DataSet();
        SqlDataAdapter sdaa = new SqlDataAdapter(sqq,conn);
        try
        {
        sdaa.Fill(dst);
        return dst;
        }
        catch (Exception ex)
        {
        throw new Exception(ex.Message);
        }
        finally
        {
        conn.Close();
        }
        }

        注意:DropDownList1_SelectedIndexChanged 事件,AutoPostBack="True"

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        asp.net DropDownList 三級聯動下拉菜單實現代碼

        asp.net DropDownList 三級聯動下拉菜單實現代碼: 代碼如下:if (!IsPostBack) { //一級分類列表 this.DropDownList1.DataSource = dsbb.SelectSubjct1(); this.DropDownList1.DataTextField = cName; this.DropDownList1.DataValueField = Ccode
        推薦度:
        標簽: 三級 net 代碼代碼
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 亚洲依依成人精品| 亚洲中文字幕久久精品无码A| 成人福利免费视频| 国产l精品国产亚洲区在线观看| 国产精品午夜免费观看网站| 国产亚洲精久久久久久无码AV| 国产特黄特色的大片观看免费视频| 国产成人精品久久亚洲高清不卡 | 成人特级毛片69免费观看| 亚洲综合网站色欲色欲| 人妻在线日韩免费视频| 亚洲欧洲免费视频| 67194成手机免费观看| 亚洲一区二区三区在线观看蜜桃| 和日本免费不卡在线v| 亚洲AV日韩AV一区二区三曲| 亚洲A丁香五香天堂网| 精品国产麻豆免费人成网站| 911精品国产亚洲日本美国韩国| 日韩免费一区二区三区在线播放| 亚洲国产成人综合精品| 亚洲精品A在线观看| 黄色网址在线免费| 国产成人精品亚洲日本在线| 四虎永久免费影院| 免费无码黄网站在线看| wwwxxx亚洲| 伊人久久精品亚洲午夜| 91精品视频在线免费观看| 亚洲精品乱码久久久久久V| 国产专区一va亚洲v天堂| 59pao成国产成视频永久免费| 亚洲日韩看片无码电影| 亚洲午夜久久久久妓女影院| 国产妇乱子伦视频免费| 国产亚洲成在线播放va| 久久亚洲AV成人无码国产 | 久久精品国产亚洲av麻豆小说| 黄瓜视频影院在线观看免费| 亚洲免费日韩无码系列| 丁香婷婷亚洲六月综合色|