I am using webmatrix 2 with razor syntax. One of the fields from my database has value 1 or 0. I want to show the field in my webgrid as a checkbox. Below is the code I have tried:
@grid.GetHtml(
tableStyle : "table",
alternatingRowStyle : "alternate",
headerStyle : "header",
columns:
grid.Column(header: "Active", format: (col)=>@Html.Raw("<input type='checkbox' checked='"+ ((col.Active) ? "checked" :"") + "' disabled='true' />"))
I noticed that the above code shows the column with all checkbox checked.
Try like this:
This assumes that the
Activeproperty is boolean on your model and not integer. If it is integer you might adapt the test: