I have a model for a drop down menu similar to this one. I am trying to create a controller for it.
public ActionResult Index()
{
ViewBag.Message = "Welcome to ASP.NET MVC!";
return View(new MyData());
}
And I create my View like this
@Html.DropDownListFor(m => m.State,
new SelectList(Model.StateList, "Value", "Text"))
But I am receiving the error below for the line above:
Compiler Error Message: CS1061: 'System.Collections.Generic.List<Projects.Models.MyData>' does not contain a definition for 'StateList' and no extension method 'StateList' accepting a first argument of type 'System.Collections.Generic.List<Projects.Models.MyData>' could be found (are you missing a using directive or an assembly reference?)
Can you please direct me what I am doing wrong?
the problem is
@model List<ProjectName.Models.MyData>simply change it to
cheers!