Check This How To Bind DropDownList Using List Collection and DataSet in Asp.Net
Let’s take Countries ‘enum’ as follows
enum enCountries:int{India =0,USA ,UK ,UAE};
Let see How to Bind the DropDownList With Enum
ddlEnumBind.Items.Add("--Select
Country--");
//get enum items to get the respective enum value
string[]
enumNames=Enum.GetNames(typeof(enCountries));
foreach (string item in enumNames)
{
//get the enum
item value
int
value = (int)Enum.Parse(typeof(enCountries),
item);
ListItem
listItem = new ListItem(item,
value.ToString());
ddlEnumBind.Items.Add(listItem);
}
0 comments:
Respects for your's Questions & Opinions