0 c# rendering model view asp.net-mvc-4
我正在尝试为我的项目渲染数据集合.
消息来源:
控制器中的数据绑定确实运行得很好,但我无法渲染模型View,这是从Controller.
我收到这样的错误:
the name 'model' does not exist in the current context
我不明白为什么?我收到这样的错误,因为另一个View的其他模型渲染效果很好,但不是这个.
谁能解释我,发生问题的原因是什么?
谢谢
它应该Model不是model:
@foreach(var item in Model)
{
<tr>
<td>@item.ContractGuid</td>
<td>@item.SenderId</td>
<td>@item.ContractStatus</td>
<td>@item.CreditEnd</td>
</tr>
}
Run Code Online (Sandbox Code Playgroud)
小写model用于定义模型的类型,它将被传递给视图(例如@model List<MvcApplication6.Models.ContractPlain>),而资本 Model用于访问它(例如Model.First())
另一件事是这样Html.DisplayText做不起作用,所以你可以删除它(就像我做的那样)或用它替换它Html.DisplayFor