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)%>

 

posted @ 2013-01-14 17:36  南潇湘  阅读(202)  评论(0编辑  收藏  举报