I am using DetailsView
which its DefaultMode
: insert, and I want to make its checkbox to be checked by default also user can change it to unchecked, but to bind checkbox we should use
Checked='<%# Bind("Cit_Visible") %>'
and this lets the default status of checkbox to be unchecked, so how can I solve this?
You can assign value to text property of checkbox if you want your check box selected at the time of data binding.
<asp:CheckBox ID="chl" runat="Server" Checked="true" Text="<%# Bind('Cit_Visible') %>" />
on code behind you can access text value to save it to in DB
CheckBox MyCheckbox = new CheckBox();
MyCheckbox = (CheckBox)DetailsView1.FindControl("chl");
Response.Write(MyCheckbox.Checked);