C# ViewModel不包含电子邮件的定义

C# ViewModel不包含电子邮件的定义,c#,asp.net-mvc,asp.net-mvc-4,C#,Asp.net Mvc,Asp.net Mvc 4,我试图用一个视图绑定两个UserManagerFeedback模型,但由于视图不包含电子邮件的任何定义,所以我面临一个问题……以下是我的全部代码 public class FeedbackMixModel { public List<UserManager> allUserManagers { get; set; } public List<Feedback> allfeedbacks { get; set; } }

我试图用一个视图绑定两个
UserManager
Feedback
模型,但由于视图不包含电子邮件的任何定义,所以我面临一个问题……以下是我的全部代码

public  class FeedbackMixModel
    {

        public List<UserManager> allUserManagers { get; set; }

        public List<Feedback> allfeedbacks { get; set; }

    }
视图==>>

@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>
@model WebApplication5.Models.FeedbackMixModel
@DisplayNameFor(model=>model.Email)
@DisplayNameFor(model=>model.CurrentStorage)
@DisplayNameFor(model=>model.MaxStorage)
@DisplayNameFor(model=>model.LastLoginMonth)
@foreach(Model.allUserManager中的var项)
{
@DisplayFor(modelItem=>item.Email)
@DisplayFor(modelItem=>item.CurrentStorage)
@DisplayFor(modelItem=>item.MaxStorage)
@DisplayFor(modelItem=>item.LastLoginMonth)
}

我完全不知道如何解决这个问题。。。其中,电子邮件在
UserManager
类中定义了如果我做错了什么,我如何访问您的实际
反馈混合模型
模型本身没有您打算用于标题的属性的定义:

<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>
或者,您可以尝试以集合中的第一个元素为目标,类似于:


@DisplayNameFor(x=>Model.AllUserManager[0]。电子邮件)
@DisplayNameFor(x=>Model.allUserManager[0].CurrentStorage)
@DisplayNameFor(x=>Model.allUserManager[0].MaxStorage)
@Html.DisplayNameFor(x=>Model.allUserManager[0].LastLoginMonth)

您的
反馈混合模型
没有
电子邮件
属性。它也没有
CurrentStorage
MaxStorage
LastLoginMonth
。这些属性位于何处?这些属性位于userManager类中这是视图模型包含两个其他模型userManager和反馈电子邮件,其他属性在userManager类中定义是否有任何方法可以访问它们???您可以使用与仍然使用
DisplayNameFor()的方法类似的方法
helper尝试解析适当的属性名称。
<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>
<thead>
    <tr>
        <th>
          Email
        </th>
        <th>
          Current Storage
        </th>
        <th>
          Max Storage
        </th>
        <th>
          Last Login Month
        </th>
      </tr>
 </thead>
<thead>
    <tr>
        <th>
          @Html.DisplayNameFor(x => Model.allUserManagers[0].Email)
        </th>
        <th>
          @Html.DisplayNameFor(x => Model.allUserManagers[0].CurrentStorage)
        </th>
        <th>
          @Html.DisplayNameFor(x => Model.allUserManagers[0].MaxStorage)
        </th>
        <th>
          @Html.DisplayNameFor(x => Model.allUserManagers[0].LastLoginMonth)
        </th>
      </tr>
 </thead>