Bootstrap FreeKB - MVC - Create a drop down selector
MVC - Create a drop down selector

Updated:   |  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 Buy Me A Coffee



Comments


Add a Comment


Please enter ece9a8 in the box below so that we can be sure you are a human.