protected void btndelete_Click(object sender, EventArgs e) { CheckBox cb = new CheckBox(); bool flag = false; for (int i = 0; i < GridView1.Rows.Count; i++) { cb = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1"); if (cb.Checked) { int id = Convert.ToInt32(GridView1.Rows[i].Cells[3].Text); objfeedbackdal.deleteFeedback(id); flag = false; } } if (flag) { bindgrid(); Response.Write("<script>alert('Record deleted');</script>"); } else { Response.Write("<script>alert('Please select record to delete');</script>"); } }