I am trying to poulate a DropDownList with the contents of a Dictionary which is like this:
public static readonly IDictionary<string, string> VideoProviderDictionary = new Dictionary<string, string>
{
{"1", "Atlantic"},
{"2", "Blue Ridge"},
...
For the model I have:
public string[] VideoProvider { get; set; }
public IEnumerable<SelectListItem> Items { get; set; }
In the controller, I am trying to populate the list:
[HttpGet]
public ActionResult Register()
{
var model = new RegisterViewModel();
model.Items = new SelectList(VideoProviders.VideoProviderDictionary);
return View(model);
}
The issue is in the markup, there is no overload for DropDownList that takes a lambda expression:
@Html.DropDownList(Model -> model.Items)
I tried to use:
@Html.DropDownListFor(model => model.Items)
But I get the error:
CS1501: No overload for method 'DropDownListFor' takes 1 arguments