View:
@model IEnumerable<models.AppModel>
@using (Html.BeginForm()){
<table>
<tr>
<td>
@Html.LabelFor(model => model.Age) //error
</td>
</tr>
</table>
}
Controller:
public ActionResult Index(){
if (string.IsNullOrWhiteSpace(unitCode))
{
return View(entity.dBSet.ToList());
}
else // do something else
}
Model:
namespace models{
public class AppModel{
public short Age {get; set;}
public string Nationality {get; set;}
}
}
In the view, every property of the model class such as Model.Age
, Model.Nationality
has this error. How do I fix it?