Using the MVC helper DropDownList will save you from writing all of the html. Here is an example that sets parameter values ββin a view.
<div class="col-md-10"> @Html.DropDownListFor(model => model.NumberParticipant, new SelectList(new [] { new {value="",text=""}, new {value="2",text="2"}, new {value="3",text="3"}, new {value="4",text="4"}, new {value="5",text="5"} },"value","text"), new { htmlAttributes = new { @class = "form-control" }}) </div>
It would be best practice to add a property of type SelectList to the model class and set possible options. You can then refer to the new property in the helper as follows:
<div class="col-md-10"> @Html.DropDownListFor(model => model.NumberParticipant, Model.MySelectList, new { htmlAttributes = new { @class = "form-control" }}) </div>
source share