如何在這種情況下正確使用@if?使用條件
它總是告訴我expected ;
,但它不起作用。
這裏是我的代碼:
@foreach (var item in Model)
{
<tr>
<td>
@Html.ActionLink(item.Client.Surname + ", " + item.Client.FirstName, "Details", "Assessments", new { id = item.ClientID }, null)
</td>
<td>
@if (item.Doctor.Surname != null)
{
@Html.DisplayFor(modelItem => item.Doctor.Surname) , @Html.DisplayFor(modelItem => item.Doctor.FirstName)
} //here -- ; expected-- i tried adding ; but it doesn't work
</td>
<td>
@Html.DisplayFor(modelItem => item.ReferFor)
</td>
}
我希望發生的是,當Doctor.Surname
爲空時,它會留下一個空白<td>
在哪一行它說 - 預期; – Yogi
@Yogi我編輯我的職務,所以你可以看到哪些行 – kielou
裹在''逗號 - '@ Html.DisplayFor(..),'@ Html.DisplayFor(..)' –