So the problem is displaying a data bound read-only checkbox or radio button in a GridView without actually disabling those controls.
I assume you know what templates are in a GridView. Examples are in VB.NET. Sorry...
So as a first step create a function in the page's underlying class that returns the string "checked" based on the bound data. Here's what I did. The underlying data table is storing bool values in bit fields.
Expand|Select|Wrap|Line Numbers
- Protected Function TrueToChecked(ByVal str As String) As String
- Dim retval As String = ""
- If "True" = str Then retval = "checked"
- Return retval
- End Function
[HTML]
<ItemTemplate>
exclude<input type="radio" <%# TrueToChecked(Eval("force_exclude")) %> onclick="window.focus();return false;"/>
<input type="radio" <%# TrueToChecked(Eval("force_include")) %> onclick="window.focus();return false;"/>include
</ItemTemplate>
[/HTML]
The TrueToChecked() function will be called with the string representation of the underlying data, every time the DataBind method of the ItemTemplate is called.
The control will be readonly thanks to the small JavaScript code hooked up to the 'onclick' event of the control.
Note, that the controls do not have the 'name' attribute defined. If you give a name, the radiobuttons will be treated as one group, and clicking on one, will uncheck all the others even though the JavaScript will prevent updating any of them. If for some reason you need to give names, add another function to the class that returns a unique name on every call. You can call this function to return a string as name the same way the TrueToChecked() function is called in the example. For checkboxes it does not matter.