查看:
@model IEnumerable<models.AppModel>
@using (Html.BeginForm()){
<table>
<tr>
<td>
@Html.LabelFor(model => model.Age) //error
</td>
</tr>
</table>
}
控制器:
public ActionResult Index(){
if (string.IsNullOrWhiteSpace(unitCode))
{
return View(entity.dBSet.ToList());
}
else // do something else
}
型号:
namespace models{
public class AppModel{
public short Age {get; set;}
public string Nationality {get; set;}
}
}
在视图中,模型类的每个属性(例如Model.Age
,Model.Nationality
都有此错误。我该如何解决?