0
Я добавил IF условие ввиду MVC3 но не работает:IF условие ввиду MVC3
@model IEnumerable<StudentRegistrationPortal.Models.CourseRegisterModel>
@{
ViewBag.Title = "Welcome Student";
}
<h2>Welcome
@Context.User.Identity.Name
</h2>
@Html.ActionLink("[Sign Out]", "SignOut", "Student")
<ul>
<li>@Html.ActionLink("Register Courses", "registerCourses", "Course")</li>
</ul>
<h3>Pending Courses</h3>
<table border="1">
<tr>
<th>RollNumber
</th>
<th>Course Code
</th>
<th>Course Name
</th>
<th>Status</th>
</tr>
@foreach (StudentRegistrationPortal.Models.CourseRegisterModel modelValue in Model)
{
if (!string.IsNullOrEmpty(modelValue.Course.Code))
{
<tr>
<td>
@Context.User.Identity.Name
</td>
<td>
@Html.DisplayFor(modelItem => modelValue.Course.Code)
</td>
<td>
@Html.DisplayFor(modelItem => modelValue.Course.Name)
</td>
<td>Pending
</td>
</tr>
}
}
</table>
Это дает следующее сообщение об ошибке при выполнении IF заявления: Object reference not set to an instance of an object.
Цель IF условие для подтверждения что значение modelValue.Course.Code
не пустое или пустое.
resharper 101: D – phillip