I wanted to display a previously selected item from a dropdown list. With what i have so far i only get the id displayed of the item selected from the dropdown previously. I would like to get the text/description name of the item rather than its ID number.
This is what i have for the viewModel:
[LocalizedDisplayName("BillingRate", NameResourceType = typeof(User))]
public short BillingRateId { get; set; }
[UIHint("DropDownList")]
[DropDownList(DropDownListTargetProperty = "BillingRateId")]
public IEnumerable<SelectListItem> BillingRates { get; set; }
This is what i have for the .ascx form page:
<%:Html.LabelFor(m => m.BillingRateId)%>
<%:Html.EditorFor(m => m.BillingRateId, Model.BillingRates)%>
<%:Html.ValidationMessageFor(m => m.BillingRateId)%>
When i run and view page i get in the description box : 4
when it should be : Internship
You could make a simple service that will return just that string, then use jQuery AJAX to populate it.
Then in your javascript: