does not contain a definition for 'DropDownList'

asp.net-mvc, asp.net-mvc-4

Solution

This is how I was able to achieve a resolution, in case anybody else needs to know.

@Html.DropDownListFor(model => item.Type.Value, new SelectList(ViewBag.DropDownLoadRecoveryType,  "Value", "Text", item.Type))

Problem

UPDATE: since its my `DropDownTypes` is a collection so I try to pass something like this: it works but the only problem i'm having is that its selecting the default value which is whatever the index of 0 and my `item.Type` is the selected value ``` @Html.DropDownListFor(m => item.Type, new SelectList(item.DropDownTypes.Select(x => x.Text))) ``` What I'm doing wrong here, I'm trying to load the dropdownlist 'System.Web.Mvc.HtmlHelper>' does not contain a definition for 'DropDownList' and the best extension method overload 'System.Web.Mvc.Html.SelectExtensions.DropDownList(System.Web.Mvc.HtmlHelper, string, System.Collections.Generic.IEnumerable, object)' has some invalid arguments ``` @model IEnumerable<web.Models.CollectionViewModel> @foreach (var item in Model ) { <tr> <td> @Html.DropDownList(item.DropDownTypes, (IEnumerable<SelectListItem>)ViewBag.DropDownLoadRecoveryType, new { @class = "form-control" }) </td> </tr> } ```

Original source