MVC - Create a drop down selector
by
Jeremy Canfield |
Updated: March 20 2020
| MVC articles
Folowing is the syntax of the DropDownListFor code to create a drop-down selector in MVC. Replace "created_by" with the column name from your SQL database.
@Html.DropDownListFor(model => model.created_by,
new List<SelectListItem>
{
new SelectListItem() {Text = "John Doe", Value="John Doe"},
new SelectListItem() {Text = "Jane Doe", Value="Jane Doe"}
},
new { @class = "form-control" })
Did you find this article helpful?
If so, consider buying me a coffee over at