/// <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 grdFinances_RowCommand(object sender, GridViewCommandEventArgs e) { string message = string.Empty; if (e.CommandName == "EditRow") { //ShowHideSections(true, false); ViewState["FINANCE_ID"] = e.CommandArgument; ProjectBLL objProjectBLL = new ProjectBLL(); FinancierBO objFinancier = objProjectBLL.GetProjectFinancierByID(Convert.ToInt32(ViewState["FINANCE_ID"])); txtFinancierName.Text = objFinancier.FinancierName; ddlCondition.ClearSelection(); if (ddlCondition.Items.FindByValue(objFinancier.FINANCECONDITIONID.ToString()) != null) { ddlCondition.Items.FindByValue(objFinancier.FINANCECONDITIONID.ToString()).Selected = true; } ddlNature.ClearSelection(); if (ddlNature.Items.FindByValue(objFinancier.FINANCENATUREID.ToString()) != null) { ddlNature.Items.FindByValue(objFinancier.FINANCENATUREID.ToString()).Selected = true; } ddlReason.ClearSelection(); if (ddlReason.Items.FindByValue(objFinancier.FINANCEREASONID.ToString()) != null) { ddlReason.Items.FindByValue(objFinancier.FINANCEREASONID.ToString()).Selected = true; } SetUpdateMode(true); } else if (e.CommandName == "DeleteRow") { string financeID = e.CommandArgument.ToString(); ProjectBLL objProjectBLL = new ProjectBLL(); message = objProjectBLL.DeleteProjectForFinance(Convert.ToInt32(financeID)); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data deleted successfully"; } ClearFields(); SetUpdateMode(false); BindFinanciers(); } if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } }