asp.net mvc 如何将controller 里一个action 返回值为list<>的值输出到view
asp.net mvc 如何将controller 里一个action 返回值为list<>的值输出到view
日期:2016-09-03 09:54:24 人气:2
我的做法,希望对你有帮助:
在controller中:return View(myRole.ToList());
在view文件开头加上:@model IEnumerable,注意 IEnumerable.
使用(定义了一个叫role的model):
@foreach(var role in Model){
@Html.DisplayFor(roleID=>role.RoleID)
@Html.DisplayFor(role