Exemplo n.º 1
0
        /// <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 grdDistrict_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string message = string.Empty;

            if (e.CommandName == "EditRow")
            {
                ShowHideSections(true, false);
                ViewState["District_ID"] = e.CommandArgument;
                DistrictBLL objDistrictBLL = new DistrictBLL();
                DistrictBO  objDistrict    = objDistrictBLL.GetDistrictById(Convert.ToInt32(ViewState["District_ID"]));

                txtDistrict.Text = objDistrict.DistrictName;
                btnSave.Text     = "Update";
                btnClear.Text    = "Cancel";
            }
            else if (e.CommandName == "DeleteRow")
            {
                // ViewState["CDAPBUDGETID"] = e.CommandArgument;
                DistrictBLL DistrictBLLobj = new DistrictBLL();
                message = DistrictBLLobj.DeleteDistrict(Convert.ToInt32(e.CommandArgument));
                if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                {
                    message = "Data deleted successfully";
                }
                SetUpdateMode(false);
                BindGrid();
                ClearData();
            }
            if (message != "")
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true);
            }
        }