枚举类型作为数据源绑定到dropdownlist控件---(转)

主要运用到System.Enum命名空间下的两个方法: GetValues(), GetName().

    #region BindState
    /// <summary>
    /// 绑定出差状态
    /// </summary>
    private void BindState()
    {
        foreach (int i in System.Enum.GetValues(typeof(EvectionState)))
        {
            string text = System.Enum.GetName(typeof(EvectionState), i);
            this.ddlState.Items.Add(new ListItem(text, i.ToString()));
        }
        this.ddlState.Items.Insert(0, new ListItem());
    }
    #endregion

 

posted @ 2016-03-15 16:46  Allure·千机  阅读(147)  评论(0编辑  收藏  举报