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

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" })


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

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


Web design by yours truely - me, myself, and I   |   |