如何在學分列中顯示學生徵集的所有課程的學分數。在學分列中,顯示學生徵集的所有課程的學分數
我需要修改Contoso大學的應用程序。
查看:
@model PagedList.IPagedList<ContosoUniversity.Models.Student>
@using PagedList.Mvc;
<h2>Students</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
@using (Html.BeginForm("Index", "Student", FormMethod.Get))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<p>
Find by name: @Html.TextBox("SearchString", ViewBag.CurrentFilter as string)
<input type="submit" value="Filter" />
</p>
}
<table class="table">
<tr>
<th>
@Html.ActionLink("Last Name", "Index", new { sortOrder = ViewBag.NameSortParm })
</th>
<th>
First Name
</th>
<th>
@Html.ActionLink("Enrollment Date", "Index", new { sortOrder = ViewBag.DateSortParm })
</th>
<th>
Date Of Birth
</th>
<th>
Courses
</th>
<th>
Credits
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.LastName)
</td>
<td>
@Html.DisplayFor(modelItem => item.FirstMidName)
</td>
<td>
@Html.DisplayFor(modelItem => item.EnrollmentDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateOfBirth)
</td>
<td>
@string.Join(",", item.Enrollments.Select(e => e.Course.Title))
</td>
<td>
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
@Html.ActionLink("Details", "Details", new { id=item.ID }) |
@Html.ActionLink("Delete", "Delete", new { id=item.ID })
</td>
</tr>
}
</table>
<br />
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount
@Html.PagedListPager(Model, page => Url.Action("Index",
new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }))
請幫助!
我不明白該怎麼做!
如果有人需要更多的細節,請告訴我。
「ContosoUniversity.Models.Student」不包含關於「薩姆」和沒有擴展方法的定義「薩姆」接受第一個參數可以找到'ContosoUniversity.Models.Student'類型(你是否缺少使用指令或程序集引用?) – Romancevic 2014-10-06 18:29:54
當然不是! :)更新了我的代碼,以免出現錯誤。 – Erik 2014-10-06 18:33:24
你是對的!謝謝! – Romancevic 2014-10-06 18:37:49