【发布时间】:2013-10-15 23:29:30
【问题描述】:
目前我在视图中显示枚举名称值,如下所示:
@foreach (var item in Model.DrawDatesList)
{
<tr id="tableHeadRows">
<td class="tableHeadRowsInside">
@Html.DisplayFor(modelItem => item.LotteryId)
</td>
<td class="tableHeadRowsInside">
@Enum.GetName(typeof(MediaBug.Shared.Enumerators.Days), item.DayId)
</td>
...
一切正常。
但这是在foreach pagedList中使用的。 我在这样的操作中检索它:
var results = ClientRepositoryBuilder
.Instance
.LotteryClientRepository
.GetAllDrawDates()
.ToPagedList(page, this.pageSize);
var model = new LotteryIndexViewModel();
model.DrawDatesList = results;
return this.PartialView(model);
是否有任何选项我不在视图中使用 @Enum.GetName(typeof(MediaBug.Shared.Enumerators.Days), item.DayId) 并以某种方式在模型中分配它?但我不知道怎么做,因为你必须在 foreach 中使用它,你不能将它“插入”到 ToList 中。
【问题讨论】:
-
什么是
item.DayId?
标签: c# asp.net-mvc enums