I have the data seeded into a list on the index page into a table and this is the model for the album to create it using entity frame work, this is all the Model.cs
public enum genre { Rock=1, Pop=2 }
public class Album
{
public int AlbumID { get; set; }
public string AlbumName { get; set; }
public string AlbumArtist { get; set; }
public genre AlbumGenre { get; set; }
public Album()
{
GenreList = new List<SelectListItem>();
}
public IEnumerable<SelectListItem> GenreList { get; set; }
public List<Artist> Artists { get; set; }
}
The controller has the following code for the dropdown list. I get a redline under model
in the code at the end, here return View(model);
however when I run it, it doesn't specify this as the answer.
public ActionResult Index()
{
Album model = new Album();
IEnumerable<genre> genres = Enum.GetValues(typeof (genre)).Cast<genre>();
model.GenreList = from action in genres
select new SelectListItem
{
Text = action.ToString(),
Value = (action.ToString())
};
return View(model);
}
and my index page is where it shows the error.
@Html.DropDownListFor(model => model.AlbumID, model.GenreList)
is the line in which I get the error on AlbumId
and GenreList
@model IEnumerable<revision.Models.Album>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create WOW", "Create"
</p>
@Html.DropDownListFor(model => model.AlbumID, Model.GenreList)