dropdownlist無刷新聯動方法集合

http://www.cnblogs.com/gwazy/archive/2005/05/10/152312.aspx 

demo:http://www.cnblogs.com/Files/gwazy/WebService.rar

[多級聯動下拉選擇框]和[Tree to Tree] 續http://webuc.net/dotey/archive/2004/08/13/1651.aspx

Ajax實現無刷新三聯動下拉框http://singlepine.cnblogs.com/archive/2006/01/18/257954.html

無刷新三級聯動:http://blog.csdn.net/allenlf/archive/2006/08/13/1056581.aspx

二級聯動不同瀏覽器:http://oftengo.com/info/450-1.htm

解答:http://www.lemongtree.com/zh-cn/item.0000102.aspx

SqlConnection con = new SqlConnection("server=localhost;database=gswebDB;uid=sa;pwd=;");
    SqlDataAdapter da = new SqlDataAdapter("select ClassName,ClassID from classname where ClassLevel=1",con);
    DataSet ds = new DataSet();
    da.Fill(ds);
    this.DropDownList1.DataSource=ds.Tables[0].DefaultView;
    this.DropDownList1.DataTextField = "ClassName";
    this.DropDownList1.DataValueField = "ClassID";
    this.DropDownList1.DataBind();
    
this.DropDownList1.Attributes.Add("onchange","load(this.options[this.selectedIndex].value)"); 
//將ClassID作爲參數傳遞給腳本函數load(ClassID),如果要傳遞的是ClassName,應將value改爲innerText,但如果大類爲中文,則調用小類時出現無法顯示的問題
   // 
this.DropDownList2.Attributes.Add("onChange","javascript:document.Form1.TH.value=this.options[this.selectedIndex].value;");   //讀取DropDownList2的值,將其賦給一個TextBox控件TH,以獲取DropDownList2的值,爲獲取DropDownList2的值,網上有人說可通過使用隱藏的TextBox控件來獲取,我未能實現,因爲在客戶端隱藏的TextBox控件也是不可用腳本來訪問的,沒法給其賦值,我只能通過將其樣式、字體顏色設於背景相同來達到隱藏效果,這是一個很笨的方法,有誰有好的方法,請幫我。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章