format a webgrid in mvc4 with html helper

丶灬走出姿态 提交于 2019-12-13 02:21:59

问题


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:


You should be able to do this:

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


来源:https://stackoverflow.com/questions/26998510/format-a-webgrid-in-mvc4-with-html-helper

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!