list 集合

 

 

1、Model

public class ROLE_FUNCTION
{

  //角色集合
  public List< ROLE> ROLES { get; set; }

  //角色权限集合
  public List<ROLEFUNCTION> ROLEFUNCTIONS { get; set; }
}

 

2、controller

  ROLE_FUNCTION R_F = new ROLE_FUNCTION();

    //角色
  R_F.ROLES = db.ROLE.Where(p => p.ROLETYPE != "超级管理员").ToList();

  //角色权限
  R_F.ROLEFUNCTIONS = db.ROLEFUNCTION.ToList();

3、 视图

@model TRSLMS.Data.Models.ViewModel.ROLE_FUNCTION

@foreach (var role in Model.ROLES)
{
  <tr>
  <td class="font_left" width="15%">
  <div align="center">@role.ROLENAME</div>
  </td>
@{string s = null;}
  @foreach (var func in Model.ROLEFUNCTIONS)
{
  if (role.ID == func.ROLEID)
  {
  s += func.FUNCTIONNAME + " ";
  }
}

<td class="font_left width="70%" onclick="ShowRole('@role.ID','@role.ROLENAME')">
<div align="center">@s</div>
</td>
<td class="font_left" width="15%">
<div align="center">
<input type="button" onclick ="fun(@role.ID);" value =" 菜单授权"/>
|
<input type="button" onclick ="FunButton('@role.ID ','@role.ROLENAME ');" value =" 页面授权"/>
</div>
</td>
</tr>
}

posted @ 2015-10-20 13:18  骚年丶勿忘初心。  阅读(143)  评论(0编辑  收藏  举报