protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e) { string strMsg = string.Empty; if (e.CommandName == "cmdEdit") { Response.Redirect("ClaimToComp.aspx?ClaimHeadIdno=" + e.CommandArgument, true); } else if (e.CommandName == "cmddelete") { objClaimToDAL = new ClaimToDAL(); long intValue = objClaimToDAL.Delete(Convert.ToInt32(e.CommandArgument)); objClaimToDAL = null; if (intValue > 0) { this.BindGrid(); strMsg = "Record deleted successfully."; } else { if (intValue == -1) { strMsg = "Record can not be deleted. It is in use!"; } else { strMsg = "Record not deleted."; } } ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true); } }