This project is read-only.

Adding Checkbox to gridview

Mar 27, 2014 at 10:23 PM
I used entity framework to build my model and I have my data displaying in a grid view now. However, I have several fields that have a value of Y or N and I want to display this data as checkboxes. I have used the RenderValueAs to create the checkboxes, but nothing I do will set the checkbox values correctly. I just want to do something like: if model.value = 'Y' then checked, else unchecked.

How can I accomplish this?
Apr 5, 2014 at 8:24 AM
you can setup 'checked' attribute of input element, besed on your condition:
<input type="checkbox" checked="@model.X == 5" />
Please see for more infomation about conditional attributes: