How to Bind Enum Types to the DropDownList?

后端 未结 6 1189
终归单人心
终归单人心 2020-12-24 11:29

If I have the following enum

public enum EmployeeType
{
    Manager = 1,
    TeamLeader,
    Senior,
    Junior
}

and I have DropDownList

6条回答
  •  萌比男神i
    2020-12-24 12:02

    Even simpler:

     ddl.DataSource = Enum.GetValues(typeof(EmployeeType));
    

    Then to go back:

    EmployeeType etSelected = (EmployeeType)ddl.SelectedValue;
    

提交回复
热议问题