(i) Level three linkage
To achieve the effect:
Code:
1Mydbdatacontext context =NewMydbdatacontext ();2 protected voidPage_Load (Objectsender, EventArgs e)3 {4 //IsPostBack If the current request is opened for the first time, it is false when it is first opened and true at all other times .5 //Add this sentence to each load page before writing the code6 if(!IsPostBack)7 {8 Showprod ();9 Showbrand ();Ten Showcar (); One } A } - /// <summary> - ///Show car name the /// </summary> - Private voidShowcar () - { - varQ = Context. Car.where (p=>p.brand==dropdownlist2.selectedvalue); + //Binding Display -Dropdownlist3.datasource =Q; +Dropdownlist3.datatextfield ="Name"; ADropdownlist3.datavaluefield ="Code"; at Dropdownlist3.databind (); - } - /// <summary> - ///Show Series name - /// </summary> - Private voidShowbrand () in { - varQ = Context. Brand.where (p=>p.prod_code==dropdownlist1.selectedvalue); toDropdownlist2.datasource =Q; +Dropdownlist2.datatextfield ="Brand_Name"; -Dropdownlist2.datavaluefield ="Brand_Code"; the Dropdownlist2.databind (); * } $ /// <summary>Panax Notoginseng ///Show Vendor Name - /// </summary> the /// <param name= "context" ></param> + Private voidShowprod () A { the varQ =context. Productor; +Dropdownlist1.datasource =Q; -Dropdownlist1.datatextfield ="Prod_name"; $Dropdownlist1.datavaluefield ="Prod_code"; $ Dropdownlist1.databind (); - } - /// <summary> the ///When a drop- down list maker changes the selection - /// </summary>Wuyi /// <param name= "Sender" ></param> the /// <param name= "E" ></param> - protected voidDropDownList1_SelectedIndexChanged (Objectsender, EventArgs e) Wu { - Showbrand (); About Showcar (); $ } - /// <summary> - ///when the dropdown series changes the selection - /// </summary> A /// <param name= "Sender" ></param> + /// <param name= "E" ></param> the protected voidDropdownlist2_selectedindexchanged (Objectsender, EventArgs e) - { $ Showcar (); the}
three-level linkage source code
Then hit the AutoPostBack property to True:
(unlike WinForm, b/s needs to be submitted to the server, otherwise each click on the Options page will reload, resulting in options cannot be changed)
2014.12.06 ASP. Three-level linkage, add employees, modify employees