天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

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 三級聯動下拉菜單實現代碼,轉載需保留來源!

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

主站蜘蛛池模板: 欧美s00老人 | xx69美国 | 就去色电影 | 76人遣返航班上71人呈阳性 | 免费成年人在线视频 | 久久久久亚洲 | 免费三级现频在线观看 | 亚洲一级毛片免费在线观看 | 久久免费资源福利资源站 | 久久国产免费观看精品1 | 高H内射NP古文 | 18禁无遮遮挡羞漫画免费阅读 | 精品人妻一区二区三区视频53 | 国产成人精品午夜福麻豆报告 | 欧美精品专区第1页 | ass女人下部欣赏 | 麻豆AV蜜桃AV久久 | 久久黄色网址 | 亚洲AV香蕉一区区二区三区蜜桃 | 色婷婷99综合久久久精品 | 亚洲高清免费在线观看 | 好爽别插了无码视频 | 免费播放美女一级毛片 | 国模啪啪久久久久久久 | 久久久久久久久女黄 | hd性欧美俱乐部中文 | 亚洲欧美日韩人成 | 大胆国模一区二区三区伊人 | 小草观看免费高清视频 | 妖精视频免费高清观看 | 久久久久婷婷国产综合青草 | 疯狂第一次国语 | 国产视频精品免费 | 看 视频一一级毛片 | 脱女学小内内摸出水网站免费 | 韩国女人高潮嗷嗷叫视频 | 91欧洲在线视精品在亚洲 | 99久久久无码国产精品免费人妻 | 国产色婷亚洲99精品AV在 | 国产爱豆果冻传媒在线观看 | 无人区尖叫之夜美女姐姐视频 |