2014.12.06 ASP. Three-level linkage, add employees, modify employees

Source: Internet
Author: User

(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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.