/ Published in: C#
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
enum Speed { Low = 1, Medium = 2, High = 3 } protected void Page_Load(object sender, EventArgs e) { DropDownList1.DataSource = htSpeed; DropDownList1.DataValueField = "key"; DropDownList1.DataTextField = "value"; DropDownList1.DataBind(); } protected Hashtable BindEnum(Type speedEnum) { string[] enumNm = Enum.GetNames(speedEnum); int[] enumVal = (int[])Enum.GetValues(speedEnum); for (int cnt = 0; cnt < enumVal.Length; cnt++) { htSpeed.Add(enumVal.GetValue(cnt), enumNm[cnt]); } return htSpeed; }