我的 view.aspx 中有这一行我没有使用剃须刀:
<p style="color:Red">
<% Html.DropDownListFor(model => model.AllSundays, new SelectList(Model.AllSundays)); %>
</p>
当我运行我的程序并查看源代码时,那里什么都没有。我在我的行动中使用了 ViewModel 我有:
var allSundaysInThisMonth = new SundaysInMonthViewModel
{
AllSundays = sundays.Select(x => new SelectListItem
{
Value = x.ToString("dd-MM-yyyy"),
Text = x.ToString("dd-MM-yyyy"),
})
};
var selectedSunday = new SundaysInMonthViewModel{
SelectedSunday = thisMonthSundays.Where(x => x < now)
.Last().ToString("dd-MM-yyyy")
};
return View(allSundaysInThisMonth);
谢谢