I am trying to create a drop down list within my create view. For example, I want the drop down selection "AM" to map to the value "0" for the "Wednesday" property within my model. So far, I have this code:
<div class="editor-label">
<%: Html.LabelFor(model => model.Wednesday) %>
<%: Html.DropDownListFor(model => model.Wednesday, new SelectList(new List<SelectListItem>(){new SelectListItem{Text = "AM", Value = "0"}}))%>
</div>
When testing this in the browser, the only item in the drop down list has the text "System.Web.Mvc.SelectListItem." Instead, I want it to display the user-friendly text "AM."
What am I doing wrong?
This worked for me:
@Html.DropDownListFor(model => model.CompanyName, new List<SelectListItem>{new SelectListItem{Text = "AM", Value = "0"}})