protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } //Si no existe la variable Categorias en el objeto CACHE if (Cache["Categorias"] == null) { //traemos las categorias de la BD var categorias = _logicaNegocio.SeleccionarCategorias(); //Creamos la variable Categorias en el objeto CACHE Cache.Insert( "Categorias", categorias, null, DateTime.UtcNow.AddMinutes(1), Cache.NoSlidingExpiration); gvCategorias.DataSource = categorias; gvCategorias.DataBind(); } else { gvCategorias.DataSource = Cache["Categorias"]; gvCategorias.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { //try //{ if (IsPostBack) { return; } Trace.Write("Este es el metodo Page_Load"); //throw new Exception("EXCEPTION GENERADA"); //object o1 = "a"; // int i2 = (int)o1; //Traemos las categorias desde la capa de negocio var categorias = _logicaNegocio.SeleccionarCategorias().ToList(); //Al resultado de categorias, le agregamos en la posicion 0 //la opcion TODOS categorias.Insert(0, new Categoria { CategoriaID = 0, Nombre = "TODOS" }); //Lo asignamos al dropdownlist ddlFiltroCategoria.DataSource = categorias; ddlFiltroCategoria.DataBind(); Buscar(); //} //catch (InvalidCastException ex1) //{ // litError.Text = ex1.Message; //} //catch (Exception ex) //{ // litError.Text = ex.Message; //} //finally //{ // litError.Text += ". FINALLY"; //} }
// GET: /Product/Create public ActionResult Create() { ViewBag.Categorias = _logicaNegocio.SeleccionarCategorias(); return(View()); }