Binding wrong on select ASP.NET MVC option

0

When I give a form post to Controller , the binding on asp-for="VehiclePlate" takes value from option from select ( @vehicle.Category ). However, I want to get the text of option of select ( @vehicle.Plate ) in Controller . How do I do this?

This is select :

@model Exam
...
<select asp-for="VehiclePlate" id="listVehicle" data-init-plugin="select2" style="width: 100%">
    @foreach (var vehicle in ViewBag.Vehicles)
    {
       <option value="@vehicle.Category">@vehicle.Plate</option>
    }
</select>

This is Controller :

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Create(Exam exam)
{
  ...
}
    
asked by anonymous 21.12.2017 / 17:02

0 answers