How do I display a different label text from the value as done with a dropdown list in MVC 5 EF 6?

asp.net-mvc asp.net-mvc-5 entity-framework entity-framework-6

Question

My Oracle table currently has Y/N entries for Enable and Disable. Enable and Disable are available from a dropdown list when editing a row.

<div class="form-group">
  @Html.LabelFor(model => model.FLAG, htmlAttributes: new { @class ="control-  label col-md-2" })
<div class="col-md-10">
@Html.DropDownList("FLAG", new List<SelectListItem>{new SelectListItem{Text ="Enable",Value="Y",Selected=true},
new SelectListItem{Text ="Disable",Value="N"}})
@Html.ValidationMessageFor(model => model.FLAG, "", new { @class = "text-danger" })</div></div>

My Problem

The Value of the column "Y" is displayed on the index page where the records are displayed. Instead of the value "Y" or the value "N," I would like to have Enabled and disabled displayed on the index page. Is there a dropdownlist-type HTML helper that displays a label with a personalized message dependent on value, like I did with the SelectListItem?

1
2
1/5/2016 9:26:08 AM

Accepted Answer

ZZZ_tmp
0
1/4/2016 9:33:20 PM

Popular Answer

ZZZ_tmp


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow