我在运行MVC Html Razor时收到错误Object reference not set to an instance of an object.
。我在google上搜索如何在剃须刀中创建IF-Else
并找到一些好的答案。但就我而言,我收到了一个错误。
我的代码
<td style="text-align: left" >
<div id="divEBSN">
@if (Model.RCEducationalBackground.School.SchooldName != null)
{
<span style="color: Red">@Html.DisplayFor(model => model.RCEducationalBackground.School.SchooldName)</span>
}
else {
<span style ="color:Red">@Html.DisplayFor(model => model.RCEducationalBackground.SchoolNameEducBG)</span>
}
</div>
</td>