elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Usando Git para manipular el directorio de trabajo, el índice y commits (segunda parte)


  Mostrar Mensajes
Páginas: [1]
1  Programación / .NET (C#, VB.NET, ASP) / Colo enlazo un inputselect con una tabla en mi base de datos en: 24 Noviembre 2021, 15:05 pm
cómo me pueden ayudar, le explico: tengo dos tablas
Artículo: ID de tipo INT, título de tipo  NVARCHAR,CategoriId de tipo INT, precio de tipo MONEY y la tabla Categoria: ID de tipo INT, nombre de
tipo NVARCHAR, descripción de tipo NVARCHAR

 Y tengo el siguiente código que me ayuda a obtener una lista de mis categorías:
Código
  1.    public Task<List<CategoryModels>> GetCategory()
  2.        {
  3.            string sql = "Select * from dbo.Category";
  4.            return _db.LoadData<CategoryModels, dynamic>
  5.                (sql, new
  6.                { });
  7.  
  8.        }  
       


Quiero vincular esta lista a una inputselect para poder seleccionar una categoría y así ingresar un producto


Código
  1.         <EditForm Model="@newArticle" OnValidSubmit="@InsertArticle">
  2.    <DataAnnotationsValidator />
  3.    <ValidationSummary />
  4.    <head>
  5.        <style type="text/css">
  6.            label {
  7.                width: 100px;
  8.                display: inline-block;
  9.            }
  10.        </style>
  11.    </head>
  12.  
  13.    <label>Title</label> <InputText id="title" @bind-Value="newArticle.Title" />
  14.    <p></p>
  15.  
  16. This section is where I want my categories to appear
  17.    <label>Category</label><InputSelect @bind-Value="newArticle.CategoryId"></InputSelect>
  18.    <p> </p>
  19.    <label>Price</label> <InputNumber @bind-Value="newArticle.Price" />
  20.  
  21.  
  22.    <button type="submit" class="btn btn-primary">Agregar</button>
  23. </EditForm>    
 

Estoy trabajando con la aplicación del  blazor server en la plataforma asp.net core 3.1
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines