<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
        主站蜘蛛池模板: 亚洲VA综合VA国产产VA中| av无码久久久久不卡免费网站| 日韩电影免费在线| 亚洲中文字幕久久精品蜜桃 | japanese色国产在线看免费| 国产福利免费观看| 男男gvh肉在线观看免费| 免费在线一级毛片| 一级人做人a爰免费视频| 亚洲午夜福利AV一区二区无码| 国产人成网在线播放VA免费| 亚洲另类激情综合偷自拍图| 精品视频在线免费观看| 亚洲色四在线视频观看| 曰批视频免费30分钟成人| 亚洲日韩一区二区一无码| 国产免费观看青青草原网站| 一区二区三区免费视频播放器 | 在线日本高清免费不卡| 亚洲AV无码久久久久网站蜜桃 | 久久久久久国产精品免费免费| 中文字幕乱码亚洲无线三区 | 中国极品美軳免费观看| 亚洲日韩中文字幕天堂不卡| 最近的中文字幕大全免费版| 免费国产a理论片| 亚洲国产成人私人影院| 四虎永久在线精品免费网址| v片免费在线观看| 亚洲男人天堂影院| 国产aa免费视频| 日韩电影免费在线观看| 亚洲一区二区三区高清在线观看| 亚洲av无码成人精品区在线播放| 97视频免费观看2区| 亚洲乱亚洲乱妇24p| 亚洲va无码手机在线电影| 成人免费看片又大又黄| 99久久免费国产特黄| 亚洲成人激情小说| 亚洲国产精品无码AAA片|