一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

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

復制代碼 代碼如下:
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"

AspNet技術asp.net DropDownList 三級聯動下拉菜單實現代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 成人a毛片手机免费播放 | 欧美高清亚洲欧美一区h | 久久露脸国产精品 | 五月天最新网址 | 亚洲一区色 | 亚洲欧美另类久久久精品能播放的 | 亚洲精品美女久久久久 | 亚洲一区二区三区视频 | 日本在线一区二区 | 国产成综合 | 韩国福利影视一区二区三区 | 欧美一级做一a做片性视频 欧美一级做一级做片性十三 | 久草社区| 成人午夜免费福利视频 | 综合激情五月婷婷 | 久久国产加勒比精品无码 | 国语精品视频在线观看不卡 | 99在线在线视频免费视频观看 | 国产高清一级毛片在线人 | 伊人网站 | 欧美a级黄色片 | 草草线在成人免费视频 | 精品自拍一区 | 欧洲视频在线观看 | 国产香蕉成人综合精品视频 | 久久精品91 | 中文一区在线观看 | 精品国产午夜肉伦伦影院 | 亚洲福利国产 | 国产精品永久免费视频观看 | 美女特级毛片 | 日日嗷 | 精品国产96亚洲一区二区三区 | 好吊色青青青国产欧美日韩 | 久久国产精品-久久精品 | 麻豆精品久久久一区二区 | 美女视频很黄很a免费国产 美女视频黄.免费网址 | 一区二区在线观看视频 | 亚洲人成网77777亚洲 | 欧美一级欧美一级高清 | 欧美一级成人免费大片 |