protected void FillGridExtras(Alimento alimento) { listaExtras.RemoveAll(); List <ExtraDisponible> lista = aDAL.GetExtrasDisponibles(alimento.IdAlimento); foreach (ExtraDisponible item in lista) { listaExtras.AddExtra(item); } LoadGridExtrasDisponibles(); }
protected void GridViewExtras_RowCommand(object sender, GridViewCommandEventArgs e) { try { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = ((GridView)sender).Rows[index]; LinkButton btnAdd = (LinkButton)row.FindControl("btnPlus"); LinkButton btnSubstract = (LinkButton)row.FindControl("btnMinus"); Label lblCantidad = row.FindControl("lblCantidad") as Label; int idAlimentoPedido = Convert.ToInt32(lblModalCodigo.Text); int idAlimento = carrito.GetListAlimentos().FirstOrDefault(x => x.IdAlimentoPedido == idAlimentoPedido).IdAlimento.Value; int idIngrediente = Convert.ToInt32((row.FindControl("lblCodigo") as Label).Text); ExtraDisponible extraDisp = eDDAL.FindByAlimentoAndIngrediente(idAlimento, idIngrediente); ViewState["AlimentoPedido"] = idAlimentoPedido; switch (e.CommandName) { case "SubstractOne": SubstractExtra(extraDisp); break; case "AddOne": AddExtra(extraDisp); break; } GridViewExtras.DataSource = aDAL.GetExtrasDisponibles(idAlimento); GridViewExtras.DataBind(); } catch (Exception ex) { UserMessage(ex.Message, "danger"); } }