Adding a hyphen to the html attribute name using MVC3 WebGrid helper

I am afraid that this is not possible. Unfortunately the WebGrid it doesn’t support the same syntax as standard HTML helper such as TextBoxFor where you could:

@Html.TextBoxFor(x => x.SomeProp, new { data_test = "testdata" })

and the underscore would be automatically converted to dash.

Leave a Comment