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();
查看全文
相关阅读:
netty的基本使用
netty 实现简单的rpc调用
NIO 的基本使用
BIO实现 Socket 通信
springboot使用ElasticSearch
docker-compose安装rabbitmq集群(主从集群---》镜像集群)
杂谈:面向微服务的体系结构评审中需要问的三个问题
使用Spring Boot和RxJava的构建响应式REST API
JVM体系结构详解
如何成为更好的程序员?
原文地址:https://www.cnblogs.com/DotNet1010/p/1154065.html
最新文章
电商后台系统-订单系统-订单状态的梳理(跨境电商)
《电商后台系统是个什么玩意》
pikachu Unsafe Fileupload
pikachu Unsafe Filedownload 不安全的文件下载
pikachu Files Inclusion
pikachu RCE远程系统命令执行
pikachu SQL Injection
pikachu CSRF
pikachu XSS
js利用cookie登录网站
热门文章
pikachu 暴力破解
闲聊 Exp/Imp 命令使用
GDI 开发的准备工作
Qss样式(二)
QSS 样式表 (一)
QWidget使用qss样式的background-image属性
Crawl Spider 汽车之家中宝马5系全部图片
Scrapy 实现需要登录简单网站的爬取(以登录人人网为例)
Crawl Spider 爬取微信小程序社区信息
python3.8 安装scrapy及其使用 ,爬取糗事百科小案例
Copyright © 2011-2022 走看看