zoukankan
html css js c++ java
DropDownList 绑定 枚举 Enum
public
static
List
<
ListItem
>
GetEnumList(Type enumType,
bool
allAllOption)
{
if
(enumType.IsEnum
==
false
)
{
return
null
;
}
List
<
ListItem
>
list
=
new
List
<
ListItem
>
();
if
(allAllOption
==
true
)
{
list.Add(
new
ListItem(
"
--全部--
"
,
""
));
}
Type typeDescription
=
typeof
(DescriptionAttribute);
System.Reflection.FieldInfo[] fields
=
enumType.GetFields();
string
strText
=
string
.Empty;
string
strValue
=
string
.Empty;
foreach
(FieldInfo field
in
fields)
{
if
(field.IsSpecialName)
continue
;
strValue
=
field.GetRawConstantValue().ToString();
object
[] arr
=
field.GetCustomAttributes(typeDescription,
true
);
if
(arr.Length
>
0
)
{
strText
=
(arr[
0
]
as
DescriptionAttribute).Description;
}
else
{
strText
=
field.Name;
}
list.Add(
new
ListItem(strText, strValue));
}
return
list;
}
/**/
///
</summary>
///
派驻申请的状态
///
</summary>
public
enum
AccreditStatus
{
/**/
///
<summary>
///
已经结束
///
</summary>
[Description(
"
结束
"
)]
Pass
=
2
,
/**/
///
<summary>
///
新建
///
</summary>
[Description(
"
新建
"
)]
New
=
0
,
/**/
///
<summary>
///
在审批中
///
</summary>
[Description(
"
审批中
"
)]
Running
=
1
,
/**/
///
<summary>
///
被拒绝
///
</summary>
[Description(
"
被拒绝
"
)]
Refuse
=
-
1
}
this.ddlState.DataSource = Global.GetEnumList(typeof(AccreditStatus), true);
this.ddlState.DataTextField = "Text";
this.ddlState.DataValueField = "Value";
this.ddlState.DataBind();
查看全文
相关阅读:
deepin 安装微信与QQ
安装git
在ubuntu上安装最新稳定版本的node及npm
如何恢复Initial commit之前的源文件
git使用之错误分析及解决(持续更新)
【翻译】在Ext JS 5应用程序中如何使用路由
【翻译】Sencha Ext JS 5发布
【翻译】Ext JS 4——Ajax和Rest代理处理服务器端一场和消息的方法
【翻译】Ext JS——高效的编码风格指南
【翻译】在Ext JS 5种使用ViewControllers
原文地址:https://www.cnblogs.com/DotNet1010/p/1154065.html
最新文章
java根据开始时间结束时间计算中间间隔日期
Java常用工具类---XML工具类、数据验证工具类
文件夹内多文件上传到服务器
Java常用工具类---IP工具类、File文件工具类
python多个装饰器的执行顺序
马云: 贸易若停止 战争将开始
深度剖析:如何实现一个 Virtual DOM 算法
BigPipe 大的页面分割成一个一个管道
如何让你前端的右手更专业 --- 待续
设置 placeholder 字体颜色 : ::
热门文章
在 windows 开发 reactNative 的环境 搭建过程 react-native-android
使用 Koa + MongoDB + Redis 搭建论坛系统
一个用vue-cli vue-router2.1 vue 2.1 vuex2.1 echarts统计 express 的 时间轴 记录每天活动
vue 和 react 选择
Draggabilly – 轻松实现拖放功能(Drag & Drop)
deepin网络加速
vue学习:props,scope,slot,ref,is,slot,sync等知识点
将本地项目上传到码云
promise介绍
Promise 的基础用法
Copyright © 2011-2022 走看看