I'm trying to create a drop down list in an ASP.NET MVC3 view based on a list of allowed values linked to the model.
So far, in my model, I've got:
namespace NS
{
public class Model
{
public Model()
{
Status = new List<SelectListItem>();
Status.Add(new SelectListItem { Text = "New", Value = "New" });
Status.Add(new SelectListItem { Text = "PaymentPending", Value = "PaymentPending" });
Status.Add(new SelectListItem { Text = "PaymentProcessed", Value = "PaymentProcessed" });
Status.Add(new SelectListItem { Text = "Dispatched", Value = "Dispatched" });
Status.Add(new SelectListItem { Text = "Complete", Value = "Complete" });
Status.Add(new SelectListItem { Text = "Cancelled", Value = "Cancelled" });
}
public List<SelectListItem> Status { get; set; }
} // class Model
} // NS
(obviously trimming unneccessary stuff out)
Then in my view I've got:
@model NS.Model
@Html.DropDownListFor(Model.Status)
As looking at answers on SO seems to suggest. But I get an error:
Compiler Error Message: CS1501: No overload for method 'DropDownListFor' takes 1 arguments
Any hints much appreciated.