Sajid Hussain

Sajid Hussain

  • 1.1k
  • 509
  • 94.3k

How to handle Checkbox in asp c#

Oct 1 2014 6:26 AM
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);             }         }