protected void lbtndel_Click(object sender, EventArgs e) { int j = 0; for (int i = 0; i < gvroom.Rows.Count; i++) { CheckBox cb = (CheckBox)gvroom.Rows[i].FindControl("cbsel"); if (cb.Checked) { j = j + 1; int id = int.Parse(gvroom.DataKeys[i].Value.ToString()); room myRoom = new room(); myRoom.DeleteRoom(id); } } if (j == 0) { Response.Write("<script>alert('请选择要删除的考场')</script>"); } else { BindData(); } }