【发布时间】:2016-11-01 13:30:38
【问题描述】:
我正在尝试将两个 UserManager Feedback 模型与一个视图绑定,但鉴于视图不包含任何电子邮件定义,我遇到了问题......这是我的所有代码
public class FeedbackMixModel
{
public List<UserManager> allUserManagers { get; set; }
public List<Feedback> allfeedbacks { get; set; }
}
控制器==>>>
var user = db.UserManagers.ToList();
var feedbacks = db.Feedbacks.ToList();
var Model = new FeedbackMixModel
{
allUserManagers =user,
allfeedbacks=feedbacks
};
return View(Model);
查看==>>
@model WebApplication5.Models.FeedbackMixModel
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<!-- Main content -->
<table class="pretty" id="dt">
<thead>
<tr>
<th >
@Html.DisplayNameFor(model => model.Email)
</th>
<th>
@Html.DisplayNameFor(model => model.CurrentStorage)
</th>
<th>
@Html.DisplayNameFor(model => model.MaxStorage)
</th>
<th>
@Html.DisplayNameFor(model => model.LastLoginMonth)
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.allUserManagers)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Email)
</td>
<td>
@Html.DisplayFor(modelItem => item.CurrentStorage)
</td>
<td>
@Html.DisplayFor(modelItem => item.MaxStorage)
</td>
<td>
@Html.DisplayFor(modelItem => item.LastLoginMonth)
</td>
</tr>
}
</tbody>
</table>
我很困惑如何解决这个问题...电子邮件在UserManager 类中定义如果我做错了什么我可以访问
【问题讨论】:
-
您的
FeedbackMixModel没有Email属性。它也没有CurrentStorage、MaxStorage或LastLoginMonth。这些房产位于哪里? -
这些属性位于 userManager 类中
标签: c# asp.net-mvc asp.net-mvc-4