I have a grid like this:
WebGrid grid = new WebGrid(source: Model, rowsPerPage: 5, ajaxUpdateContainerId: "GridContainer");
Now, I want to display "MyContent" column as raw HTML. What should I do?
<div id="GridContainer">
@grid.GetHtml(columns:
grid.Columns(
grid.Column(
columnName: "MyContent",
//Format: What should I put here?
)
)
)
</div>
Use
<div id="GridContainer">
@grid.GetHtml(columns:
grid.Columns(
grid.Column(
columnName: "MyContent",
format: (item) =>
{
var links = Html.ActionLink("Edit", "Edit", new {id = item.PrimaryKey}) + " | " +
Html.ActionLink("Details","Details", new { id = item.PrimaryKey}) + " | "+
Html.ActionLink("Delete", "Delete", new { id = item.PrimaryKey});
return Html.Raw(links);
}
)
)
)
which renders as
<td>
<a href="/Home/Edit/5">Edit</a> |
<a href="/Home/Details/5">Details</a> |
<a href="/Home/Delete/5">Delete</a>
</td>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With