Reputation: 21
Controller Code:
List Months = new List();
Months.Add("Jan");
Months.Add("Feb");
ViewData["Months"] = new SelectList(Months);
View Code:
${Html.DropDownList((SelectList)ViewData["Months"])}
Error: Argument 2: cannot convert from 'System.Web.Mvc.SelectList' to 'string'
Upvotes: 0
Views: 302
Reputation: 1288
The error is pretty clear, it states that it expects a type of string and you are passing a SelectList make sure you use the correct overloads.
@Html.DropDownList("Months",selectList: ((SelectList)ViewData["Months"]))
Upvotes: 0