码迷,mamicode.com
首页 > 其他好文 > 详细

下拉列表绑定枚举类型值

时间:2016-07-06 18:23:11      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:

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
    {
      Task = 344,
      Fax = 345,
      Phone = 346,
      Email = 347,
      Reminder = 348,
      Appointment = 349,
      Expiration = 350,
      Inquiry = 367
    }
  }

 

下拉列表绑定枚举类型值

标签:

原文地址:http://www.cnblogs.com/xiaomen/p/5647491.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!