MvcScaffold Version: 0.9.7
Okay, so MvcScaffold generates this code for me in my _CreateOrEdit.cshtml partial view:
<div class="editor-field">
@Html.DropDownListFor(model => model.LocationId, ((IEnumerable<JobSite.Models.Location>)ViewBag.PossibleLocations).Select(option => new SelectListItem {
Text = Html.DisplayTextFor(_ => option).ToString(),
Value = option.LocationId.ToString(),
Selected = (Model != null) && (option.LocationId == Model.LocationId)
}), "Choose...")
@Html.ValidationMessageFor(model => model.LocationId)
</div>
This however generates the following HTML:
<select data-val="true" data-val-number="The field LocationId must be a number." data-val-required="The LocationId field is required." id="LocationId" name="LocationId"><option value="">Choose...</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
As you will see the drowndown "text" is being displayed the same as the "value".
Obviously I can re-touch this code manually each time by doing:
Text = Html.DisplayTextFor(_ => option.LocationName).ToString(),
...but I would like to fix the issue to avoid this.
Can anyone offer any guidance?
Thanks Paul