protected void Page_Load(object sender, EventArgs e) { User user = (User)Session["user"]; if (!string.IsNullOrEmpty(Request.QueryString["Delete"]) && (User)Session["user"] != null && ((User)Session["user"]).IsAdmin) { var isInt = int.TryParse(Request.QueryString["Delete"], out int id); if (isInt) { var brandBll = new BrandBll(); try { brandBll.DeleteBrand(id); Response.Redirect("Brands.aspx"); } catch (Exception exception) { error.InnerText = exception.Message; } } } RenderGrid(); }