gridview delete on selected checkbox

string cs = ConfigurationManager.AppSettings["victedudb"];
        cn = new SqlConnection(cs);
        cn.Open();
        foreach (GridViewRow row1 in GridView1.Rows)
        {
            var chk = (CheckBox)row1.FindControl("ch1");
            if (chk.Checked)
            {
                string k = "delete from demoresult where email=N'" + row1.Cells[2].Text + "' and category=N'" + row1.Cells[3].Text + "'";
                cm = new SqlCommand(k, cn);
                cm.ExecuteNonQuery();
               

            }
        }

Popular Posts