一、枚举 #region GroupGrade:用户组等级 /// /// 用户组等级 /// public enum GroupGrade { /// /// 一级 /// 一级 = 1, /// /// 二级 /// 二级 = 2, /// /// 三级 /// 三级 = 3, /// /// 四级 /// 四级 = 4, /// /// 五级 /// 五级 = 5, /// /// 六级 /// 六级 = 6 } #endregion 二、实现绑定的方法 /// /// 对DropDownList对象执行数据绑定 /// /// 要绑定的DropDownList对象 /// 枚举类型 /// 默认值 /// 第一项提示字符 public static void DropDownList(ref DropDownList select, Type type, string value, string prompt) { select.Items.Clear(); if (prompt != null && prompt != "") { ListItem dl = new ListItem(prompt, ""); select.Items.Add(dl); } if (type != null) { int i = 0; string[] names = Enum.GetNames(type); foreach (int v in Enum.GetValues(type)) { ListItem li = new ListItem(names, v.ToString()); if (value == v.ToString()) li.Selected = true; select.Items.Add(li); } } } 三、使用示例DropDownList(ref DropDownList1, typeof(GroupGrade), null, "选择等级");