正确使用@Html.DropDownListfor

Proper usage of @Html.DropDownListfor

我有这个文本框:

@Html.EditorFor(model => model.Type)

Model.Type 是一个字符串。我想将其更改为该类型的 DropDownList。我想处理 View 上的列表元素,我不想为此使用 class。 我失败的尝试是这样的:

@Html.DropDownListFor(model=>model.Type, 
 new List<SelectListItem>
{
  new SelectListItem {"Horror"},
  new SelectListItem {"Fiction"},
  new SelectListItem {"Romance"},
})

这种情况下如何正确使用DropDownListFor?谢谢

快到了。这个

new SelectListItem {"Horror"}

没有意义。

应该是

new SelectListItem { Text = "Horror", Value = "Horror" }