0
我不明白爲什麼在加載表單時沒有選擇初始值。DropDownListFor未選擇初始值
這裏是我的代碼
model.LUIsUsed = new List<SelectListItem>()
{
new SelectListItem { Value = "0", Text = "Ignore" },
new SelectListItem { Value = "1", Text = "Required" },
new SelectListItem { Value = "2", Text = "Optional" },
};
在我看來
@Html.DropDownListFor(x => x.Foo[i].IsUsed, Model.LUIsUsed, new { @class= "form-control input-sm is-used" })
x.Foo[i].IsUsed
價值"1"
,但沒有選擇required
。我無法弄清楚爲什麼。
是因爲x.Foo
是數組嗎?
編輯:當我不使用的陣列,它的工作原理
你看到了嗎?舊的,但仍然可能是一個問題。 http://stackoverflow.com/questions/10506828/mvc-2-dropdownlist-not-selecting-value-in-case-of-list –