您的位置:首页 > 编程语言 > ASP

asp.net mvc 如何将controller 里一个action 返回值为list<>的值输出到view

2014-01-23 14:21 901 查看
在controller中:return View(myRole.ToList());
在view文件开头加上:@model IEnumerable<LTXYCallCenter.Models.Role>,注意 IEnumerable.
使用(定义了一个叫role的model):
@foreach(var role in Model){
<tr class="trBody">
<td><input type="radio" name="beSelected" groupname="beRadio" /></td>
<td class="tdCurrentID" value="@role.RoleID">@Html.DisplayFor(roleID=>role.RoleID)</td>
<td>@Html.DisplayFor(roleCode=>role.RoleCode)</td>
<td>@Html.DisplayFor(roleName=>role.RoleName)</td>
<td>@Html.DisplayFor(roleType=>role.RoleType)</td>
<td>@Html.DisplayFor(roleGrade=>role.RolePermitGrade)</td>
</tr>
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐