私はこのモデルがあります:のC#、MVC、代わりに、テーブルのHTML
public class CoursesTeacher
{
public int Id { get; set; }
public string FullName { get; set; }
public IEnumerable<string> CourseName { get; set; }
public IEnumerable<int> CourseId { get; set; }
}
私はかみそりで代わりにテーブルのhtmlを作成したいと思います。 先生には複数のコースがあります。
その
ように私はこのコードを書いた:
<table class="table table-bordered">
<tr>
<th>
@Html.ActionLink("Teacher Name", "RequestsTeachers")
</th>
<th>
@Html.ActionLink("Corese Name", "RequestsTeachers")
</th>
<th>
Edit
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td rowspan="@item.CourseName.Count()">
@Html.DisplayFor(modelItem => item.FullName)
</td>
@foreach (var courseName in item.CourseName)
{
<td>
@Html.DisplayFor(modelItem => courseName)
</td>
}
@foreach (var courseId in item.CourseId)
{
<td>
<div class="pull-right">
@Html.NoEncodeActionLink("<span class='glyphicon glyphicon-pencil'></span>", "Edit", "EditFinancial", "Control", routeValues: new { courseId = courseId }, htmlAttributes: new { data_modal = "", @class = "btn btn-default" })
</div>
</td>
}
</tr>
}
をしかし正しくない作成: correct
正しい作成する方法?
CoursesTeacherのCourseIdとCourseNameは右同数の要素を持っているのですか? –