How to add Html inside ASP.NET MVC 3 WebGrid column name (header)

Can't I add html inside the column name of the WebGrid (in the header)? When I add html inside the column name, webgrid encodes this. Can't add html inside webgrid column name?

+3
source share
2 answers

There is a way to modify the html created by MVC Helper, but this is not very convenient. In general, you can write this command:

@( new HtmlString( Component.HelperMethod().ToHtmlString().Replace("[replacetag]", "My Content")) ) 

Here is an example of using a grid component:

 <div id="grid"> @(new HtmlString( grid.GetHtml( tableStyle: "grid", headerStyle: "header", rowStyle: "row", footerStyle: "footer", alternatingRowStyle: "altRow", columns: grid.Columns( grid.Column("Name", "[replacethis]"), grid.Column("Surname", "Surname"), grid.Column("Email", "Sender Email"), grid.Column("Id", "", format: (item) => item.GetSelectLink("Select"), canSort: false)) ).ToHtmlString().Replace("[replacethis]", "<b>Name</b>") ) ) </div> 
+12
source

I don't think there is a way to directly write HTML in the WebGrid header. One possible solution is to add what you want with javascript on the client side.

0
source

All Articles