ASP.NET MVC DropDownListFor with model of type Ienumerable<model>

时间:2016-10-20 19:47:24

标签: asp.net-mvc-4

How to bind IEnumerable model to DropDownListFor and DropDownList @model IEnumerable @Html.DropDownListFor();

1 个答案:

答案 0 :(得分:0)

 View
 @Html.DropDownListFor(x => x.doc_typeid, Model.doctype_name, "--Select--", new {    @class = "form-control", @style="width:auto;" })
 Controller
 var docTypes = from c in db.tm_doc_type select c;
 doctype_name = new SelectList(docTypes, "doc_typeid", "doctype_name"),