I have a method to perform change on some data. Among these data, I have a dropdownlist that contains the periods of the courses. When I select to change, I need the dropdown to come with the option checked, as it is in the database.
I need it selected "Night", as it is in the database:
Here is the select of the dropdown . The @ViewBag.Periodos
I pass through the method Alterar
in Controller :
<select name="selPeriodo" class="form-control">
@{
foreach (var item in @ViewBag.Periodos)
{
<option value="@item.Id">@item.Nome</option>
}
}
</select>