I have a dropdown list that is not showing the default value in the view. After debugging I can see that the default values are being pulled with the correct values but they are not being displayed. I store my IEnumerable in my ViewModel
Example: DropDown 1 is supposed to show True (that is the value in the DB) but is showing the first value "Not Set"
View
@model IList<NavLiveWebInterface.ViewModel.Proc_Item_SKUViewModel>
for (var i = 0; i < Model.Count(); i++)
{
<div class="editor-label">
@Html.LabelFor(m => Model[i].Filterable)
</div>
<div class="editor-field">
@Html.DropDownListFor(m => Model[i].Filterable,Model[i].TrueFalse)
</div>
@Html.ValidationMessageFor(m => Model[i].Filterable,"Please Select a Value")
}
View Model
public bool? Filterable { get; set; }
public IEnumerable<SelectListItem> TrueFalse
{
get
{
return new[]
{
new SelectListItem { Value = "Not Set", Text = "Not Set" },
new SelectListItem { Value = "True", Text = "True" },
new SelectListItem { Value = "False", Text = "False" }
};
}
}