Make checkbox of detailsview to be checked by default for insert new record?

asp.net, checkbox, detailsview

Solution

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);

Problem

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?

Original source