Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 3 如何在asp.net mvc 3中显示IEnumerable项_Asp.net Mvc 3_Linq_Entity Framework_C# 4.0 - Fatal编程技术网

Asp.net mvc 3 如何在asp.net mvc 3中显示IEnumerable项

Asp.net mvc 3 如何在asp.net mvc 3中显示IEnumerable项,asp.net-mvc-3,linq,entity-framework,c#-4.0,Asp.net Mvc 3,Linq,Entity Framework,C# 4.0,我有这样的看法: @model IEnumerable<sn.Models.Order> <h2> **Name of Recipients** </h2> <p> @Html.ActionLink("Create New", "Create") </p> <table> <tr> <th> Last Name

我有这样的看法:

    @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>

@(Model.Any()?Model.First().Customer.LastName:)

@(Model.Any()?Model.First().Customer.LastName:)

感谢您的回复。在执行您给我的代码更改后,我收到了这个错误:CS0119:“System.Linq.ParallelEnumerable.First(System.Linq.ParallelQuery,System.Func)”是一个“方法”,在给定的上下文中无效,它突出显示了有问题的更改。我忘记了
First
后面的括号。我已经编辑了我的回答谢谢你的回复。在执行您给我的代码更改后,我收到了这个错误:CS0119:“System.Linq.ParallelEnumerable.First(System.Linq.ParallelQuery,System.Func)”是一个“方法”,在给定的上下文中无效,它突出显示了有问题的更改。我忘记了
First
后面的括号。我已经编辑了我的答案
var certificateDetails = db.orders.Where(p => p.ID == id);
return View( certificateDetails.ToPagedList(pageNumber, pageSize));
<h2>
    @(Model.Any() ? Model.First().Customer.LastName : "")
</h2>