I'm having a problem with my application in ASP.NET MVC. What's happening is that when it comes to saving data, my combo boxes load data from enums. These combo boxes are from an application to a school, where the series / year, the class and the shift are loaded in them. But the problem I'm having is that, at the time I'm going to edit those data that have been saved, these combo boxes return to the default value, that is, the data that is already loaded. My question is: how do I do that when trying to change this data, they load the data that has already been saved, since all other data loads normally, only the combos boxes that have this, and detail, if by chance I do not to sort the data the way it was before editing, the combos data is changed to default values.
I'll post their code here:
Year / Series
<div class="form-group">
@Html.LabelFor(model => model.Ano, new { @class = "control-label col-md-2" })
<div class="col-md-10">
<select name="Ano">
@for (int i = 5; i < 10; i++)
{
<option>@i</option>
<p>º</p>
}
</select>
@Html.ValidationMessageFor(model => model.Ano)
</div>
</div>
Class
<div class="form-group">
@Html.LabelFor(model => model.Turma, new { @class = "control-label col-md-2" })
<div class="col-md-10">
<select name="Turma">
@foreach (var item in ViewBag.Turmas)
{
<option>@item</option>
}
</select>
@Html.ValidationMessageFor(model => model.Turma)
</div>
</div>
Shift
<div class="form-group">
@Html.LabelFor(model => model.Turno, new { @class = "control-label col-md-2" })
<div class="col-md-10">
<select name="Turno">
@foreach (var item in ViewBag.Turno)
{
<option>@item</option>
}
</select>
@Html.ValidationMessageFor(model => model.Turno)
</div>
</div>