This worked for me.
@grid.GetHtml(tableStyle: "webGrid",
headerStyle: "header",
alternatingRowStyle: "alt",
selectedRowStyle: "select",
columns: grid.Columns(
grid.Column("Is Active",format: (item) =>
{
if (item.IsActive == true)
{
return Html.Raw(string.Format("<text><img height='20' width='20' src=\"{0}\" alt=\"Image\"/></text>", Url.Content("~/images/rightmark.png")));
}
else
{
return Html.Raw(string.Format("<text><img height='20' width='20' src=\"{0}\" alt=\"Image\"/></text>", Url.Content("~/Content/images/non-preview-photo.gif")));
}
}, style: "firstColumn",canSort:true),
grid.Column("Name", " Name", style: "SecondColumn",canSort:true),
grid.Column("Role", "Role", style: "ThirdColumn",canSort:true)
))
if else for WebGrid column
– Naive