I am loading some ids to a ViewBag
to use it's data in the related View.
var userAccountList =serviceResponse.RoleList.Select(x => x.RoleId).ToList();
ViewBag.UserRoles = userAccountList;
this result is a List<string>
.
In the View a Kendo Grid retrieves data from json.
@(Html.Kendo().Grid<RoleModel>().Name("KendoGrid").Scrollable().Columns(columns =>
{
columns.Bound(x => x.Id)
.HtmlAttributes(new { style = "text-align:center;"})
.ClientTemplate("# if ( Id != '3'){
#<a class='k-button' href=\"/Role/Delete/#= Id #\"><span class='k-icon k-delete' style='pointer-events: none;'></span>Delete</a># }#")
.Width(85).Sortable(false)
.Hidden(!((BaseController)this.ViewContext.Controller).UserHasPermission(PermissionType.RoleDelete));
columns.Bound(x => x.Name);
....
}
When I use static values such as '3'
I could prevent to show a
tag that was used as delete button. How can I use ViewBag.UserRoles
in this conditional if the list contains Id
that's bound to column?