format a webgrid in mvc4 with html helper

935 views Asked by At

I have the following web grid.

selectionFieldName: "selectedRow", ajaxUpdateContainerId: "gridContent");
grid.Pager(WebGridPagerModes.NextPrevious);}
<div id="gridContent">
@grid.GetHtml(tableStyle: "webGrid",
        headerStyle: "header",
        alternatingRowStyle: "alt",
        selectedRowStyle: "select",
        columns: grid.Columns(
        grid.Column("TaskID", "TaskID"),
        grid.Column("TaskDesc", " Task Desc", format:  @Html.Raw(task.TaskDesc)),
        grid.Column("TaskTitle", "Task Title", style: "description")

 ))

This line :

    grid.Column("TaskDesc", " Task Desc", format:  @Html.Raw(task.TaskDesc)),

gives me an error. Is there a way I can use @html.Raw helper within the webgird without it throwing an error ?

1

There are 1 answers

0
Tim On

You should be able to do this:

grid.Column("TaskDesc", " Task Desc", format:  (item) => Html.Raw(item.TaskDesc)),