MVC 中DropDownList 用法
MVC 中DropDownList 用法
后台
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 Dictionary<string, int> dc = new Dictionary<string, int>(); 2 dc.Add("订单提交", 0); 3 dc.Add("订单确认", 1); 4 dc.Add("已入库", 2); 5 dc.Add("代付款", 3); 6 dc.Add("已支付", 4); 7 dc.Add("出库", 5); 8 SelectList items = new SelectList(dc, "Value", "Key"); 9 ViewBag.GenderList = items;
前台
@Html.DropDownList("GenderList", (SelectList)ViewBag.GenderList, "--请选择--")
方式二
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
ViewData["city"] = new List<SelectListItem>() { new SelectListItem(){ Selected=false , Text="北京", Value="1"}, new SelectListItem(){ Selected=false , Text="上海", Value="2"}, new SelectListItem(){ Selected=false , Text="广州", Value="3"}, }; ================================== @Html.DropDownList("city")
转载 请注明原文地址并标明转载:http://www.cnblogs.com/laopo
商业用途请与我联系:lcfhn168@163.com