0
Answer

How to handle Checkbox in asp c#

Sajid Hussain

Sajid Hussain

10y
654
1
I have a web form in which a check box with code as below
<asp:CheckBox ID="txtIsPaid" runat="server" autopostback="true" OnCheckedChanged="txtIsPaid_CheckedChanged" />
is used.and in sql database datatype is bit.
but when i checked or unchecked this box the value is always false in database. i googled but in vain.
 
protected void txtIsPaid_CheckedChanged(object sender, EventArgs e)         {             if (txtIsPaid.Checked == true)             {                 EmployeeLeave empleave = new EmployeeLeave();                 empleave.IsPaid = Convert.ToBoolean(txtIsPaid.Text);             }         }