代码:
public enum PriorityEnum
{
High,
Medium,
Low
}
IQueryable<PriorityValues> priorityValues = _enumReadService.GetRecords<PriorityValues>();
var creationOptions = new CreationOptions
{
PriorityValues = priorityValues.ToList()
};
我得到的下拉菜单显示默认为"High"。但它需要是"Medium"。如何将下拉显示默认设置为“中”而不是“高”?
更新:添加渲染下拉代码
<b>@Html.Label("Priority:")</b>
@Html.DropDownListFor(x => x.PriorityValueId, Enum.GetValues(typeof (PriorityValueEnum)).OfType<PriorityValueEnum>().ToList().Select(x => new SelectListItem {Text = x.ToString(), Value = ((int) x).ToString(CultureInfo.InvariantCulture)}))