我想產生一個視圖來顯示使用內置的成員資格提供用戶列表和用戶的角色和作用。使用列表中的成員資格提供
我的模型和控制器拿起用戶和角色,但我有我的視圖中顯示他們的麻煩。
型號
public class AdminViewModel
{
public MembershipUserCollection Users { get; set; }
public string[] Roles { get; set; }
}
控制器
public ActionResult Admin()
{
AdminViewModel viewModel = new AdminViewModel
{
Users = MembershipService.GetAllUsers(),
Roles = RoleService.GetRoles()
};
return View(viewModel);
}
查看
Inherits="System.Web.Mvc.ViewPage<IEnumerable<Account.Models.AdminViewModel>>"
<table>
<tr>
<td>UserName</td>
<td>Email</td>
<td>IsOnline</td>
<td>CreationDate</td>
<td>LastLoginDate</td>
<td>LastActivityDate</td>
</tr>
<% foreach (var item in Model) { %>
<tr>
<td><%=item.UserName %></td>
<td><%=item.Email %></td>
<td><%=item.IsOnline %></td>
<td><%=item.CreationDate %></td>
<td><%=item.LastLoginDate %></td>
<td><%=item.LastActivityDate %></td>
<td><%=item.ROLE %></td>
</tr>
<% }%>
</table>
...和你有什麼樣的麻煩? – 2010-05-13 15:25:50
在我看來,我得到錯誤... Account.Models.AdminViewModel」不包含定義‘用戶名’和沒有擴展方法‘用戶名’,接受類型的第一個參數‘Account.Models.AdminViewModel’可尋(你是否缺少使用指令或程序集引用?) – Jemes 2010-05-13 15:35:31