我想根据条件是否为真更改行的背景颜色。我尝试了以下方法,但它不喜欢语法。我尝试了几种不同的方法,但它不喜欢其中任何一种
@<tr class="@if (item.ActualDeliveries <> item.ExpectedDeliveries )
then string.empty
else "style=background-color:Yellow"
End if)">
这是我得到的错误:
“If”块未终止。所有“If”块语句必须以匹配的“End If”终止。string.empty 不是 else 语句中的方法,它说“语法错误”
- 更新
即使使用以下语句,剃须刀也不会输出任何内容。但是,如果我在“</tr>”结束标记之后使用“end if”,它就可以工作。
If True Then
@:<tr>
End If
<td>
@Html.DisplayFor(Function(modelItem) currentItem.StartDate)
</td>
<td>
@Html.ActionLink("Edit", "Edit", New With {.id = currentItem.ID})
</td>
</tr>