I have a webgrid and there is a column I want to be visible only to certain users. Currently I have coded the grid as follows
if (Context.User.IsInRole(Role.
Try like this (untested, don't have access to VS at the moment):
@{
var gridColumns = new List();
gridColumns.Add(grid.Column(format: (item) => Html.ActionLink("Select", "Details", new { contractId = item.ContractId })));
if (Context.User.IsInRole(Role.Inputter) || Context.User.IsInRole(Role.Administrator))
{
gridColumns.Add(grid.Column(format: (item) => Html.ActionLink("Edit", "Edit", new { contractId = item.ContractId })));
}
gridColumns.Add(grid.Column("SignOffDate", "Sign Off Date", format: @ @item.SignOffDate.ToString("d/M/yyyy") ));
gridColumns.Add(grid.Column("FullContractNumber", "Contract Number"));
gridColumns.Add(grid.Column("ContractTitle", "Title"));
}
@grid.GetHtml(columns: grid.Columns(gridColumns.ToArray()));