how to add checked rows of datagridview into database in visual studio 2010 windows application form.
plz help
i hd written this code but throwing error on CheckBox chkbx = (CheckBox)row.FindControl("chkbx"); this line.
foreach (DataGridViewRow row in dataGridView1.Rows)
{
CheckBox chkbx = (CheckBox)row.FindControl("chkbx");
if (chkbx .Checked == true )
{
con.Close();
con.Open();
com.Connection = con;
string str = "insert into EmpDetails values ('" + row.Cells[2].Value.ToString() + "','" + row.Cells[3].Value.ToString() + "')";
com.CommandText = str;
dr = com.ExecuteReader();
MessageBox.Show("Success.....");
dr.Close();
}