我有enum
,dropdown
用于选择。我不想在1st enum
中显示NA
dropdown
。
如何exclude
来自enum
的1个元素?
public enum EmployeeStatus
{
NA = 1,
Active = 2,
InActive = 3,
Other = 5
}
@Html.DropDownListFor(model => model.EmployeeStatus, Enum.GetNames(typeof(Models.EmployeeStatus)).Select(e => new SelectListItem { Text = e }), "--Select Type--", new { @class = "form-control" })
答案 0 :(得分:6)
您可以使用Where
Enum.GetNames(typeof(Models.EmployeeStatus)).Where(x => x != "NA")