The MVC program develops a linkage query for the vehicle category. Manufacturer, series, model

Source: Internet
Author: User

Mo

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;namespacemvcapplication8.models{ Public classBrandda {PrivateMasterdatacontext _context =NewMasterdatacontext (); //Search All series         PublicList<brand>Select () {return_context.brand.tolist (); }        //according to the manufacturer Inquiry series         PublicList<brand> Selectbyprod (stringProdcode) {            varquery = _context.brand.where (p = = P.prod_code = =Prodcode); returnquery.        ToList (); }    }}
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;namespacemvcapplication8.models{ Public classCarda {PrivateMasterdatacontext _context =NewMasterdatacontext ();  PublicList<car>Select () {return_context.car.tolist (); }        //check all models by series         PublicList<car> Selectbybrand (stringBrandcode) {            varquery = _context.car.where (p = = P.brand = =Brandcode); returnquery.        ToList (); }    }}
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingSYSTEM.WEB.MVC;usingMvcapplication8.models;namespacemvcapplication8.controllers{ Public classCarscontroller:controller {//        //GET:/cars/         PublicActionResult Index (stringProdstringBrandstringcar) {            //Check all VendorsList<productor> Listprod =NewProductorda ().            Select (); //display of the Vendor drop-down tableViewbag.prods =NewSelectList (Listprod,"Prod_code","Prod_name", prod); //through the Vendor query seriesList<brand> Listbrand =NewBrandda ().            Selectbyprod (PROD); //Display of Series drop-down tablesViewbag.brands =NewSelectList (Listbrand,"Brand_Code","Brand_Name", Brand); varb = listbrand.exists (p =>p.brand_code = = Brand)? brand:listbrand[0].             Brand_Code; //find the model of a car by seriesList<car> Listcar =NewCarda ().            Selectbybrand (b); //the display of the car drop-down tableViewbag.cars =NewSelectList (Listcar,"Code","Name", car); returnView (); } [HttpGet] PublicActionResult Index () {List<Productor> Listprod =NewProductorda ().            Select (); Viewbag.prods=NewSelectList (Listprod,"Prod_code","Prod_name","P001"); List<Brand> Listbrand =NewBrandda (). Selectbyprod ("P001"); Viewbag.brands=NewSelectList (Listbrand,"Brand_Code","Brand_Name"); List<Car> Listcar =NewCarda (). Selectbybrand ("b001"); Viewbag.cars=NewSelectList (Listcar,"Code","Name"); returnView (); }    }}
@using mvcapplication8.models; @model List<MvcApplication8.Models.Car>@using mvcapplication8.controllers;@{Layout=NULL;}<! DOCTYPE html>"Viewport"Content="Width=device-width"/> <title>Index</title>@using (Html.BeginForm ("Index","Cars", FormMethod.Post)) {@Html. DropDownList ("prod", Viewbag.prods asSelectList,New{onchange="document.forms[0].submit ();"}) @Html. DropDownList ("Brand", Viewbag.brands asSelectList,New{onchange="document.forms[0].submit ();"}) @Html. DropDownList ("Car", Viewbag.cars asselectlist)} <form attion="carscontrollers"Method="Post"> </form> </div></body>

The MVC program develops a linkage query for the vehicle category. Manufacturer, series, model

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.