Let\'s say I have the following simple enum:
enum Response { Yes = 1, No = 2, Maybe = 3 }
How can I bind this enum to a DropDow
You could use linq:
var responseTypes= Enum.GetNames(typeof(Response)).Select(x => new { text = x, value = (int)Enum.Parse(typeof(Response), x) }); DropDownList.DataSource = responseTypes; DropDownList.DataTextField = "text"; DropDownList.DataValueField = "value"; DropDownList.DataBind();