/// <summary> /// Set edit mode for edit comand /// Delete data from the database for delete comand /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grdOccupation_RowCommand(object sender, GridViewCommandEventArgs e) { string message = string.Empty; if (e.CommandName == "EditRow") { ViewState["OCCUPATIONID"] = e.CommandArgument; GetOCCUPATIONDetails(); SetUpdateMode(true); ScriptManager.RegisterStartupScript(this, this.GetType(), "Added", "setDirty();", true); } else if (e.CommandName == "DeleteRow") { // ViewState["OCCUPATIONID"] = e.CommandArgument; OccupationBLL OccupationBLLobj = new OccupationBLL(); message = OccupationBLLobj.DeleteOccupation(Convert.ToInt32(e.CommandArgument)); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data Deleted successfully"; } AllClear(); BindGrid(true, true); SetUpdateMode(false); } if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } }
protected void BtnDeleteOk_Click(object sender, EventArgs e) { EntityOccupation entOccupation = new EntityOccupation(); int cnt = 0; try { foreach (GridViewRow drv in dgvOccupation.Rows) { CheckBox chkDelete = (CheckBox)drv.FindControl("chkDelete"); if (chkDelete.Checked) { LinkButton lnkOccupationCode = (LinkButton)drv.FindControl("lnkOccupationCode"); int lintOccupationCode = Convert.ToInt32(lnkOccupationCode.Text); entOccupation.PKId = lintOccupationCode; cnt = mobjOccupationBLL.DeleteOccupation(entOccupation); if (cnt > 0) { //this.modalpopupDelete.Hide(); Commons.ShowMessage("Record Deleted Successfully....", this.Page); if (dgvOccupation.Rows.Count <= 0) { pnlShow.Style.Add(HtmlTextWriterStyle.Display, "none"); hdnPanel.Value = "none"; } } else { Commons.ShowMessage("Record Not Deleted....", this.Page); } } } GetOccupation(); } catch (System.Threading.ThreadAbortException) { } catch (Exception ex) { Commons.FileLog("frmOccupationMaster - BtnDeleteOk_Click(object sender, EventArgs e)", ex); } }