0
<tbody>
@foreach (var item in Model.Roles)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@foreach (var permission in item.Permissions)
{
@Html.DisplayFor(modelItem => permission)
<br/>
}
</td>
<td>
@Html.ActionLink("Edit", "EditRole", > "Roles", new { RoleID = item.RoleID}, null) // i want when RoleID = 1, it will > hide the button
@{ if (item.RoleID == 1) // this is the condition
{
@:style = "display:none"
}
}
</td>
</tr>
}
</tbody>
請在下次嘗試格式化您的代碼。另外,爲什麼不簡單地在您的if語句中放置'Html.ActionLink()'? – Rob
http://imgur.com/a/wlEd0 – FrustratedCoder
你可以給你ActionLink一些這樣的ID - <%= Html.ActionLink(「Test Link」,「SomeAction」,「SomeController」, null,new {id = 「someID」})%> 並隱藏使用JQ內條件 – Rigin