我在 c# 中有一个 if 条件
if (item.ReporSubCategoryId == 1 || item.ReporSubCategoryId == 2 ||
item.ReporSubCategoryId == 3 || item.ReporSubCategoryId == 4)
{
<a href="@Url.Action("GetPdf", "Report", new { report = item.ReporSubCategoryId })" >@item.ReportTitle</a>
}
如果条件更改要使用三元运算符,我想这样做吗?
用于使用显示和隐藏此标签 ( style='display:Myconditions?block:None'
)
<a href="@Url.Action("GetPdf", "Report", new { report = item.ReporSubCategoryId })" >@item.ReportTitle</a>
但我试试这段代码
<a style='display:" @item.ReporSubCategoryId == 1 || @item.ReporSubCategoryId == 2 || @item.ReporSubCategoryId == 3 || @item.ReporSubCategoryId == 4 ?block:None"'href="@Url.Action("GetPdf", "Report", new { report = item.ReporSubCategoryId })" >@item.ReportTitle</a>
但它不起作用。你能为我的错误给出正确的解决方案吗?