通过枚举数组绑定ListControl

2014-07-12 17:36:01  访问(4349) 赞(0) 踩(0)



        /// <summary>
        /// 通过枚举数组绑定ListControl
        /// </summary>
        /// <param name="lc">DropDownList,RadioButtonList,CheckBoxList等下拉控件</param>
        /// <param name="emA">枚举数组</param>
        public void ListControlDataBindByEmUserRole
            (
                ListControl lc,
                SlowX.WebKnowledge.Enums.UserRole.EmUserRole[] emA
            )
        {
            
            foreach (SlowX.WebKnowledge.Enums.UserRole.EmUserRole em
                in emA)
            {
                lc.Items.Add(new ListItem(em.ToString(), ((int)em).ToString()));
            }
        }

        /// <summary>
        /// 通过枚举数组绑定ListControl的调用示例,利用枚举对应的类已经建立的枚举数组
        /// </summary>
        /// <param name="lc"></param>
        public void ListControlDataBindDemo(ListControl lc)
        {
            ListControlDataBindByEmUserRole
                (
                    lc,
                    SlowX.WebKnowledge.Enums.UserRole.EmArray
                );
        }

枚举数组定义


        /// <summary>
        /// 数组
        /// </summary>
        public readonly static EmUserRole[] EmArray = new EmUserRole[]
        {
            EmUserRole.管理员,
            EmUserRole.总经理,
            EmUserRole.部门领导,
            EmUserRole.普通职员
        };


推荐枚举定义代码
枚举代码生成工具

标签:绑定ListControl    绑定下拉框    DataBind    DropDownList    RadioButtonList    CheckBoxList    下拉框初始化 

上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)
 
  ┈全部┈  
 
(显示默认分类)