0

我有这样的看法:

    @model IEnumerable<sn.Models.Order>



 <h2>

    **Name of Recipients**

 </h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr>
        <th>
           Last Name
        </th>
        <th>
            Mark
        </th>
        <th>
           Quiz Number
        </th>
        <th>
          Pass
        </th>
        <th>
           Paid
        </th>
        <th>
           Mark Date
        </th>
     </tr>

@foreach (var item in Model)
{
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Customer.LastName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Mark)
        </td>
        <td>
                @Html.DisplayFor(modelItem => item.QuizNo)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Pass)
            </td>
             <td>
                @Html.DisplayFor(modelItem => item.Paid)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.MarkDate)
            </td>
          </tr>
    }

</table>

下面是一张显示我的观点的图片: 看法

我想显示 LastName 代替Name of Recipients。对于特定客户,LastName 项目不会更改。此视图显示该用户的详细信息,这是我用来在控​​制器中获取结果的代码的一部分:

var certificateDetails = db.orders.Where(p => p.ID == id);
return View( certificateDetails.ToPagedList(pageNumber, pageSize));
4

1 回答 1

3
<h2>
    @(Model.Any() ? Model.First().Customer.LastName : "")
</h2>
于 2012-11-26T11:54:29.430 回答