简体   繁体   English

MVC 5-部分视图未显示数据

[英]MVC 5 - Partial view not showing data

I have a company model as seen below. 我有一个如下所示的公司模型。

The company model has an IQueryable of EmailHistory (this is another model). 公司模型具有一个IQueryable of EmailHistory(这是另一个模型)。

public int Id { get; set; }
public string CompanyName { get; set; }
public IQueryable<IEmailHistory> EmailHistory { get; set; }

In my company controller i get my company details and get all my email history records, so this is my controller. 在我的公司控制人中,我获取我的公司详细信息并获取我的所有电子邮件历史记录,因此这就是我的控制人。

//Go to the repository and the company record
var companyRecord = TheRepository.GetCompany(transaction.CompanyId, User.Identity.GetUserId());

//Get the emails for this company
companyRecord.EmailHistory = TheRepository.GetEmailHistoryByCompany(User.Identity.GetUserId(),
            Id);

If i expand the results at this point in the controller i can see emails for the company.... so far everything is ok. 如果我现在在控制器中扩展结果,我可以看到该公司的电子邮件...。到目前为止,一切正常。

My company page has a partial view for the email history. 我的公司页面具有电子邮件历史记录的部分视图。

@ Html.Partial("~/Views/EmailHistory/_EmailHistories.cshtml", Model.EmailHistory);

The partial looks like this: 部分看起来像这样:

@model List<AutoSend.Model.IEmailHistory>

<table class="table">
    <thead>
        <tr>
            <th style="width:100px" class="text-left">To</th>
            <th style="width:60px" class="text-left">Sent Date</th>
            <th style="width:60px" class="text-left">OutCome</th>
            <th style="width:60px" class="text-left">Delivered Date</th>
            <th style="width:60px" class="text-left">Opened Date</th>       
        </tr>
    </thead>
    <tbody>
        @foreach (var emailHistory in Model)
        {
            <tr>
            <td class="text-left">@Html.Display(emailHistory.EmailAddress)</td>
            <td class="text-left">@Html.Display(emailHistory.SentDate.ToShortDateString())</td>
            <td class="text-left">@Html.Display(emailHistory.OutCome)</td>
            <td class="text-left">@Html.Display(emailHistory.EmailDeliveredDate.ToShortDateString())</td>
            <td class="text-left">@Html.Display(emailHistory.EmailOpened.ToShortDateString())            </td>
            </tr>
        }
    </tbody>
</table>

If i step through this i can see that we loop through the email history (and can see the values) fine but..... The page never actually renders out the data (although the associated td's are rendered) 如果我逐步执行此操作,则可以看到我们遍历了电子邮件历史记录(并可以看到值),但是.....该页面从未真正呈现出数据(尽管呈现了关联的td)

I can see the table headers and rows but no records are being shown!? 我可以看到表标题和行,但是没有显示任何记录!

如何在不使用辅助方法的情况下在tds中呈现数据。....就像@emailhistory。[yourprop] ....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM