private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == dataGridView1.Columns["status"].Index)
{
dataGridView1.Rows[e.RowIndex].Cells["status"].Value = !
(bool)dataGridView1.Rows[e.RowIndex].Cells["status"].Value;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["newConnectionString"].ConnectionString);
String str = "update DemoTable set Status=" + status +" where Sln=" +
dataGridView1.Rows[e.RowIndex].Cells["ID"].Value;
con.Open();
SqlCommand cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();
con.Close();
}
}
//it is tested one.If it will help you ,then click on the accept solution button
let me know.