protected void grdpc_RowDeleting(object sender, GridViewDeleteEventArgs e) { GridViewRow row = grdpc.Rows[e.RowIndex]; HiddenField hdnID = (HiddenField)row.FindControl("hdnID"); PlacementConsultantBL del = new PlacementConsultantBL(); RecruitmentRequestBL rbl = new RecruitmentRequestBL(); RecruitmentRequestBO rbo = new RecruitmentRequestBO(); rbo.pcid = Convert.ToInt32(hdnID.Value); int Associated = rbl.CheckPC(rbo); if (Associated != 0) { ClientScript.RegisterStartupScript(Page.GetType(), "alertMessage", "alert('Placement Consultant can't be deleted as " + Associated + " recruitment requests are associated with him/her.');window.location='HDeletePC.aspx';", true); return; } int result = del.DeletePC(Convert.ToInt32(hdnID.Value)); ClientScript.RegisterStartupScript(Page.GetType(), "alertMessage", "alert('Vacancy deleted successfully');", true); //Move to normal mode grdpc.EditIndex = -1; bind(); }