I would like to make a dropdown list, with the numbers 0-10. So users can rate something.
At the moment, I have a label: @Html.LabelFor(model=> model.RATE)
How can I modify this code that I will have a dropdown box? And that the value of the dropdown box will be stored in model.RATE?
The label is working, but it would be much better to have a dropdown menu.
SOLUTION:
@Html.DropDownListFor(model => model.RATE, Enumerable.Range(0,11).Select( x => new SelectListItem { Text = x.ToString() }));
Just create a list of
SelectListItemobjects that contain the ratings, and then useHtml.DropDownListForwith the rating stored in your model (Model.RATE).