标签:get 默认值 orderby select rem type string order sub
新手刚学mvc
controller中:
public ActionResult Index(string namelist) { var list = new List<string>(); var listQry = from d in db.Movies orderby d.name select d.name; list.AddRange(listQry.Distinct()); ViewBag.namelist = new SelectList(list); var movies = from m in db.Movies select m; if (!String.IsNullOrEmpty(namelist)) { movies = movies.Where(x => x.name == namelist); } return View(movies); }
html中:
@using (Html.BeginForm("Index", "Movies", FormMethod.Get)) { <p> 下拉列表:@Html.DropDownList("namelist", "All") <input type="submit" value="查询"><br/> </p> }
All是下拉列表显示的默认值。
标签:get 默认值 orderby select rem type string order sub
原文地址:http://www.cnblogs.com/MichaelWillLee/p/6655778.html