public ActionResult BrowseCars( string manufacturer, string model) { ViewBag.manufacturer = (from m in _carCatalogue.CarsTable select m.Name).Distinct(); ViewBag.model = (from v in _carCatalogue.CarsTable select v.Vehicle).Distinct(); var car = from t in _carCatalogue.CarsTable orderby t.Name where t.Name == manufacturer || manufacturer == null || manufacturer == "" where t.Vehicle == model || model == null || model == "" select t; return PartialView("_BrowseCars", car); }
@model IEnumerable<Model.CarsTable> <p> Use the relevant dropdowns below to find the vehicle </p> <p> @using (Html.BeginForm()) { <text> Manufacturer </text>@Html.DropDownList("manufacturer", new SelectList(ViewBag.manufacturer)) <text> Model </text>@Html.DropDownList("model", new SelectList(ViewBag.model)) <input type="submit" value="search"/> } </p> <div> <table> <tr> <th> Mnaufacturer </th> <th> Model </th> <th> Engine Size </th> <th> BHP </th> </tr> @foreach (var item in Model) { <tr> <td> @Html.DisplayFor(modelItem => item.Name) </td> <td> @Html.DisplayFor(modelItem => item.Vehicle) </td> <td> @Html.DisplayFor(modelItem => item.EngineSize) </td> <td> @Html.DisplayFor( modelItem => item.Bhp) </td> } </table>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)