protected void ContactInfoGrid_OnRowCommand(object sender, GridViewCommandEventArgs eventArgs) { if (eventArgs.CommandName == "Select") { var rowIndex = Convert.ToInt32(eventArgs.CommandArgument); var row = ContactInfoGrid.Rows[rowIndex]; var id = Convert.ToInt32(row.Cells[0].Text); var isDeleted = _contactInformationService.DeleteContactInformation(id); if (isDeleted) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "<scripts>alert('Contact deleted successfully');</scripts>", true); } else { ClientScript.RegisterStartupScript(this.GetType(), "alert", "<scripts>alert('Contact deleted successfully');</scripts>", true); } Response.Redirect("~/ContactInformationPage.aspx", false); Context.ApplicationInstance.CompleteRequest(); } }