Hi!
I used DropDownList save data to database how I can display name fruits instead Id.
<table class="table table-bordered table-responsive table-condensed">
<tr>
<th>
Name
</th>
</tr>
foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
</tr>
}
</table>
<div class="col-md-3">
<div class="form-group">
<label class="col-md-12">Name</label>
<div class="col-md-12">
@Html.DropDownList("NAME", new List<SelectListItem>{
new SelectListItem { Text = "Apple", Value = "1"},
new SelectListItem { Text = "Orange", Value = "2"},
new SelectListItem { Text = "Banan", Value = "3"}},
new SelectListItem { Text = "Cherry", Value = "4"}},
"Select", htmlAttributes: new { @class = "form-control" })
</div>
</div>
</div>
I got below result:
The result I want get name instead number: