0
<tr>
 <td>
   <asp:CheckBox ID="checkdoc" runat="server" Checked="false" />:Document
 </td>
 <td>
   <asp:CheckBox ID="checktwocheque" runat="server" Checked="false" />:Two Cheques
 </td>
 <td>
   <asp:CheckBox ID="checkIdprf" runat="server" Checked="false" />:ID Proof
 </td>
</tr>
<tr>
  <td>
   <asp:CheckBox ID="checkpancrd" runat="server" Checked="false" />:PAN Card
  </td>
  <td>
   <asp:CheckBox ID="checkAddrssprf" runat="server" Checked="false" />:Address Proof
  </td>
</tr>
<tr>
  <td colspan="4" align="center">
   <asp:Button ID="btnfarmrecordsave" runat="server" Text="Save" OnClientClick="return Validations();"
    OnClick="btnfarmrecordsave_Click" />
  </td>
</tr>

iam not using checkboxlist control then how to write code for inserting values into database using asp.net.Can anyBody helpme out.

5
  • Please explain your requirements. Commented Dec 9, 2013 at 11:39
  • i have 5 checkboxes if i selected any two or three checkboxes then i have to insert those values into database using asp.net Commented Dec 9, 2013 at 11:41
  • what is your insert query can you post it ?and what is your expected datatype in database ? Commented Dec 9, 2013 at 11:43
  • datatype is varchar and Normal insertion Procedure in sql server Commented Dec 9, 2013 at 11:47
  • So you are providing parameters ? Just convert your checkbox.checked value to string it will do . Commented Dec 9, 2013 at 11:51

1 Answer 1

2

It would be better if your expected datatype is Bit rather than varchar ,However you can insert your values as ,

 string IdProof =Convert.ToString(checkIdprf.Checked);

Change your query use column name in insert query and use ISNULL to so that if a checkbox
value is null it would be entered as FALSE rather than NULL. HERE

 INSERT INTO TABLE_NAME (COL1 ,COL2,....) values (COL1,ISNULL(IdProof,'FALSE'),COL3, etc.. )
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.