zoukankan      html  css  js  c++  java
  • C# DropDownList 绑定枚举类

    第一种

      DropDownList_Franchiser_Type.DataSource = ListTypeForEnum();
      DropDownList_Franchiser_Type.DataValueField = "value";
      DropDownList_Franchiser_Type.DataTextField = "text";
      DropDownList_Franchiser_Type.DataBind() 
    
      //转换枚举类
      public static IList ListTypeForEnum()
            {
                ArrayList list = new ArrayList();
                foreach (int i in Enum.GetValues(typeof(FranchiserEnum)))
                {
                    ListItem listitem = new ListItem(Enum.GetName(typeof(FranchiserEnum), i), i.ToString());
                    list.Add(listitem);
                }
                return list;
            }
    
    //第二种
    
      DropDownList_Franchiser_Type.DataSource = System.Enum.GetNames(typeof(FranchiserEnum));
                    DropDownList_Franchiser_Type.DataBind();
                    ListItem li = new ListItem("--请选择--", "");
                    this.DropDownList_Franchiser_Type.Items.Insert(0, li);
    
    
    //枚举
    
    
        /// <summary>
        /// 经销商类别
        /// </summary>
        public enum FranchiserEnum 
        {
            [Display(Name = "")]
            无 = 0,
            [Display(Name = "签约经销商(B类)")]
            签约经销商 = 1, 
            [Display(Name = "非签约经销商(C类)")]
            非签约经销商 = 2, 
            [Display(Name = "个人")]
            个人 = 3, 
            [Display(Name = "自有仓库")]
            自有仓库 = 4,
            [Display(Name = "其他")]
            其他 = 5,
    
        }
  • 相关阅读:
    Java并发编程(二)线程任务的中断(interrupt)
    Java并发编程(一) 两种实现多线程的方法(Thread,Runnable)
    青蛙跳台阶(Fibonacci数列)
    旋转数组的最小值
    用两个栈实现队列
    重建二叉树
    二维数组中的查找
    Lab 3-1
    Lab 1-4
    Lab 1-3
  • 原文地址:https://www.cnblogs.com/szlblog/p/7498094.html
Copyright © 2011-2022 走看看