枚举类型作为数据源绑定到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