首页 > 代码库 > @Html.DropDownList

@Html.DropDownList

    //后台 
public ActionResult OrderAdd() { var items = new List<SelectListItem>() { (new SelectListItem(){Text = "", Value = http://www.mamicode.com/"Male"}), (new SelectListItem(){Text = "", Value = http://www.mamicode.com/"female"}) }; ViewBag.sexList = items; return View(); }
//前端//默认为空@Html.DropDownList("sexList", ViewBag.sexList as  List<SelectListItem>,"")//默认为第一个值,也就是 "男"@Html.DropDownList("sexList", ViewBag.sexList as List<SelectListItem>)

 

@Html.DropDownList