我有这个字符串列表:
public static readonly List<string> LIST_ITEM_STATE = new List<string>
{
"Brand new",
"Never used",
"Slightly used",
"Used",
"Heavily used",
"Damaged",
"Ruined",
"Run for your life"
};
我正在以这种方式在课堂上构建一个选择列表:
public string mItemState { get; set; }
public IEnumerable<SelectListItem> mItemStateList { get; set; }
mItemStateList = new SelectList(ValueDomain.LIST_ITEM_STATE);
而且,在我看来,我像这样渲染下拉列表:
Item State: @Html.DropDownListFor(_item => _item.mItemState, Model.mItemStateList, String.Empty)
下拉列表就像一个魅力,但我一直在寻找在Brand New
保留String.Emtpty
选项的同时通过默认设置选定值的方法。我怎么能那样做?