Mvc 中 DropDownList
页面下拉单的应用,ViewData["atypeList"]是 List<SelectListItem>
<%=Html.DropDownList("dd", (IEnumerable < SelectListItem > )ViewData["atypeList"])%>
ListBox的应用
//准备数据
SelectListItem news = new SelectListItem { Text = "请选择", Value = null };
List<SouGeDB.Plate> plateList = ViewData["PlateList"] as List<SouGeDB.Plate>;
SelectList plates = new SelectList(plateList, "ID", "Name");
List<SelectListItem> platelist = new List<SelectListItem>();
platelist.AddRange(plates);
platelist.Insert(0, news);
//应用数据
<%=Html.ListBox("plate", platelist)%>