Razor 无需通过模型的剃须刀下拉列表

Razor 无需通过模型的剃须刀下拉列表,razor,dropdownbox,dropdownlistfor,Razor,Dropdownbox,Dropdownlistfor,如何显示此列表 var dates = new List<SelectListItem> { new SelectListItem {Selected = false, Text = "Show offers for all dates", Value = ""}, new SelectListItem {Selected = false, Text = "Show offers for today", Value = today.ToShortDateString(

如何显示此列表

var dates = new List<SelectListItem>
{
    new SelectListItem {Selected = false, Text = "Show offers for all dates", Value = ""},
    new SelectListItem {Selected = false, Text = "Show offers for today", Value = today.ToShortDateString()},
    new SelectListItem {Selected = false, Text = "Show offers for this week", Value = endOfThisWeek.ToShortDateString()},
    new SelectListItem {Selected = false, Text = "Show offers for this month", Value = endOfThisMonth.ToShortDateString()},
    new SelectListItem {Selected = false, Text = "Show offers for further out", Value = all.ToShortDateString()},
};
?

据我所知,DropDownListFor需要一个模型作为第一个参数,但我并不需要一个模型来让dropdown用于我的目的

谢谢

您可以使用

@Html.DropDownList("name", dates)
名称是id中使用的下拉列表的名称和下拉列表的名称

@Html.DropDownListFor确实适用于有模型的情况

@Html.DropDownList("name", dates)