私は私の見解m.DaysOfWeek
がIEnumerable<DateTime>
あるDisplayForが私のIEnumerableでループしないのはなぜですか<DateTime>?
@(Html.DisplayFor(m => m.DaysOfWeek, "_CourseTableDayOfWeek"))
にこのラインを持っています。
あり_CourseTableDayOfWeek.cshtmlの内容です:
@model DateTime
@{
ViewBag.Title = "CourseTableDayOfWeek";
}
<th>
@System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.DayNames[(int) Model.DayOfWeek]
<span class="dateString">Model.ToString("G")</span>
</th>
と私は次のエラーを取得:私は以下の記事を参照している場合
The model item passed into the dictionary is of type '
System.Collections.Generic.List`1[System.DateTime]
', but this dictionary requires a model item of type 'System.DateTime
'.
を:
https://stackoverflow.com/a/5652524/277067
DisplayFor
は、IEnumをループしている必要があります。それぞれのアイテムのテンプレートを表示するのは間違いでしょうか?
これは悲しいことですが、おかげです。 –
同上。これらのヘルパーのもう1つの側面は、デバッグが難しく、まったく明確ではありませんでした。 – core24
私は同じトラップに落ちました。これはまったく直感的ではないようです。私はこれがMVC 4で変わることを願っています。 –