I'm trying to select an item an then display it in the view but i don't know how to pass the value to the controller.
this is my code created via scaffold:
Controller
public IActionResult Create()
{
ViewData["ClienteID"] = new SelectList(_context.Cliente, "ID", "RUC");
ViewData["ProductoID"] = new SelectList(_context.Producto, "ID", "Nombre");
return View();
}
View
<div class="form-group">
<label asp-for="Cliente" class="col-md-2 control-label"></label>
<div class="col-md-10">
<select asp-for="ClienteID" class ="form-control" asp-items="ViewBag.ClienteID"></select>
</div>
</div>
Model
public class Cliente
{
public int ID { get; set; }
public string RUC { get; set; }
public string Nombre { get; set; }
public string Direccion { get; set; }
public ICollection<Venta> Ventas { get; set; }
public Cliente()
{
}
}