最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

asp.net項(xiàng)目開發(fā)中用到的小技巧

 更新時(shí)間:2010年03月10日 23:06:33   作者:  
項(xiàng)目中用到的小技巧
1 顯示枚舉的值:<%# (CN80s.DDPM.Model.Enum.EnumBidCardStatus)(int)Eval("PerpaidCard_Status")%>
2 為下拉框綁定枚舉:
復(fù)制代碼 代碼如下:

GetEnumList(ddlBids);
void GetEnumList(DropDownList ddl)
{
foreach (EnumBidCardType s in System.Enum.GetValues(typeof(EnumBidCardType)))
{
ddl.Items.Add(new ListItem(s.ToString(), ((int)s).ToString()));
}
}
this.ddlBids.DataSource = GetEnumList(typeof(EnumBidCardType), true);
this.ddlBids.DataTextField = "Text";
this.ddlBids.DataValueField = "Value";
this.ddlBids.DataBind();
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;
}

相關(guān)文章

最新評(píng)論

陇西县| 中西区| 靖江市| 汝阳县| 景宁| 讷河市| 稷山县| 西藏| 新绛县| 宜川县| 大竹县| 寻乌县| 曲周县| 繁峙县| 丹寨县| 九龙城区| 哈尔滨市| 饶河县| 民丰县| 葵青区| 天长市| 军事| 鹤壁市| 漳浦县| 清原| 罗甸县| 兴城市| 合川市| 达拉特旗| 绵阳市| 额尔古纳市| 闸北区| 宾阳县| 涡阳县| 兴安县| 汉中市| 泽州县| 乌海市| 九江县| 巴楚县| 喀什市|