今天看一个项目里用到了枚举作为下拉列表的数据源,感觉很不错,收藏下来,实现代码如下:

 

绑定枚举的名称:

DropDownList.DataSource= Enum.GetNames(typeof(枚举名称));
DropDownList.DataBind();

 

绑定枚举的值:

DropDownList.DataSource = Enum.GetValues(typeof(枚举名称));
DropDownList.DataBind();

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-21
  • 2022-01-20
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2022-02-23
猜你喜欢
  • 2022-12-23
  • 2021-11-18
  • 2021-05-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案