i am doing the application in grid view using check box.
Database field for checkbox is as follows;
Activate datatype bit is used
source code as follows;
<asp:TemplateField HeaderText ="select" HeaderStyle-HorizontalAlign ="left">
<itemtemplate>
<asp:CheckBox ID="chkdelete" runat = "server" ForeColor="black" />
</itemtemplate>
in aspx.cs page code as follows;
for the update the checkbox value to the database.
protected void ResultGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
TextBox txtFName = (TextBox)ResultGridView.Rows[e.RowIndex].FindControl("txtFName");
TextBox txtLName = (TextBox)ResultGridView.Rows[e.RowIndex].FindControl("txtLName");
TextBox txtCity = (TextBox)ResultGridView.Rows[e.RowIndex].FindControl("txtCity");
TextBox txtState = (TextBox)ResultGridView.Rows[e.RowIndex].FindControl("txtState");
TextBox txtCountry = (TextBox)ResultGridView.Rows[e.RowIndex].FindControl("txtCountry");
TextBox txtDescription = (TextBox)ResultGridView.Rows[e.RowIndex].FindControl("txtDescription");
SqlConnection conn = new SqlConnection("Server=(local);initial catalog=master;Trusted_Connection=True");
cmd.Connection = conn;
cmd.CommandText = "UPDATE Vendors SET VendorFName ='" + txtFName.Text + "',VendorLName ='" + txtLName.Text + "',VendorCity ='" + txtCity.Text + "',VendorState ='" + txtState.Text + "',VendorCountry ='" + txtCountry.Text + "',VendorDescription ='" + txtDescription.Text + "' WHERE VendorId='" + ResultGridView.DataKeys[e.RowIndex].Values[0].ToString() + "'";
conn.Open();
cmd.ExecuteNonQuery();
ResultGridView.EditIndex = -1;
FillVendorGrid();
conn.Close();
}
cmd.CommandText = "UPDATE Vendors SET VendorFName ='" + txtFName.Text + "',VendorLName ='" + txtLName.Text + "',VendorCity ='" + txtCity.Text + "',VendorState ='" + txtState.Text + "',VendorCountry ='" + txtCountry.Text + "',VendorDescription ='" + txtDescription.Text + "' WHERE VendorId='" + ResultGridView.DataKeys[e.RowIndex].Values[0].ToString() + "'";
from the above code how to write the checkbox update in the above code. and that checkbox value to be updated in the database.
how to write the code in asp.net using csharp.