This is how I have my checkbox column currently:
<asp:TemplateField HeaderText="Hide/Show" ItemStyle-HorizontalAlign="Center" SortExpression="Hide_Show"> <ItemTemplate> <asp:CheckBox ID="HideShowChk" runat="server" Checked='<%# Bind("Hide_Show") %>' /> </ItemTemplate> </asp:TemplateField>
I have no code in my code behind because it's not necessary. Basically, a user can check or uncheck it, but it won't be reflected in the database unless I actually go into Edit mode, check or uncheck it, and then hit update so that the changes ARE reflected in the database.
Is there a way to have it so that the checkbox is "disabled" or anything of that sort while it's not in edit mode?
You have to use edititemtemplate for enabling it in the edit mode
<edititemtemplate> <asp:CheckBox ID="HideShowChk" runat="server" Checked='<%# Bind("Hide_Show") %>' /> </edititemtemplate>
If you still want to use the check box inside the ItemTemplate make it disable using CSS or jQuery.