public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GetListType();
} private void GetListType()
{
DropDownListMenu.Items.Clear();
DropDownListMenu.DataSource = ListTypeForEnum();
DropDownListMenu.DataValueField = "Value";
DropDownListMenu.DataTextField = "Text";
DropDownListMenu.DataBind();
}
public static IList ListTypeForEnum()
{
ArrayList list = new ArrayList();
foreach (int i in Enum.GetValues(typeof(EnumActivityType)))
{
ListItem listitem = new ListItem(Enum.GetName(typeof(EnumActivityType), i), i.ToString());
list.Add(listitem);
}
return list;
}
public enum EnumActivityType
{
[Description("测试1")]//将枚举值直接转为中文
Task = ,
Fax = ,
Phone = ,
Email = ,
Reminder = ,
Appointment = ,
Expiration = ,
Inquiry =
}
}