Beispiel #1
0
        //Llamado de funcion a la logica de forma async
        public void UC_Cargar()
        {
            try
            {
                Task <List <TBL_CATEGORIA> > _taskCat = Task.Run(() => LogicaCategoria.getAllCat());
                _taskCat.Wait();
                var _listCat = _taskCat.Result;
                if (_listCat != null && _listCat.Count > 0)
                {
                    //Ordenar linq
                    var data = _listCat.OrderBy(lista => lista.CAT_NOMBRE).ToList();
                    //Insertar dregistro en la lista de categoria en el indice 0
                    data.Insert(0, new TBL_CATEGORIA {
                        CAT_NOMBRE = "Seleccione la Categoria", CAT_ID = 0
                    });
                    DropDownList1.DataSource     = data;
                    DropDownList1.DataTextField  = "CAT_NOMBRE";
                    DropDownList1.DataValueField = "CAT_ID";

                    DropDownList1.DataBind();
                }
            }
            catch (Exception ex)
            {
                throw new ArgumentException("Error" + ex.Message);
            }
        }