If you want to create a dropdown list for FileTypeID
, you could try this:
(...)
public class Genre
{
public int Id { get; set; }
public string Name { get; set; }
[ForeignKey("FileType")]
public FileType FileTypeID { get; set; }
}
public enum FileType
{
Item1,
Item2,
Item3,
Item4
}
Then, in your view:
@model YourNameSpace.Models.Genre
@{
ViewData["Title"] ="xyz";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@Html.DropDownListFor(m => m.FileTypeID, new SelectList(Enum.GetValues(typeof(FileType))), "Select FileType", new { @class = "form-control" })
You will then see a dropdown list with the four selectable items item1
-item4
and a default placeholder stating "Select FileType".
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…