protected void gvCity_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "EditRecord")
        {
            if (e.CommandArgument != null)
            {
                ViewState["CityEditActive"] = true;
                ViewState["CityID"]         = Convert.ToInt32(e.CommandArgument.ToString());
                lblModalTitle.Text          = "City Edit";

                FillControls(Convert.ToInt32(e.CommandArgument.ToString()));

                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "cityAddEditModal();", true);
            }
        }
        if (e.CommandName == "DeleteRecord")
        {
            if (e.CommandArgument != null)
            {
                CityBAL balCity = new CityBAL();

                if (balCity.Delete(Convert.ToInt32(e.CommandArgument.ToString())))
                {
                    fillCityGridview();
                    ClientScript.RegisterStartupScript(GetType(), "SweetAlert", "swal({ type: 'success', title: 'City Deleted Successfully', showConfirmButton: false, timer: 2000});", true);
                }
                else
                {
                    lblErrorMessage.Text = balCity.Message;
                }
            }
        }
    }
Beispiel #2
0
 public ActionResult Delete(int id)
 {
     try
     {
         // TODO: Add delete logic here
         CityBAL balObject = new CityBAL();
         balObject.Delete(id);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
 protected void gvCity_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteRecord")
     {
         if (e.CommandArgument != null)
         {
             CityBAL balCity = new CityBAL();
             if (balCity.Delete(Convert.ToInt32(e.CommandArgument.ToString().Trim())))
             {
                 FillCityGridView();
             }
             else
             {
                 lblMessage.Text    = balCity.Message;
                 divMessage.Visible = true;
             }
         }
     }
 }