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

asp.net項(xiàng)目開(kāi)發(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)論

金寨县| 临武县| 定襄县| 鄂温| 永修县| 泰来县| 汝阳县| 馆陶县| 那坡县| 峨边| 通州市| 莱州市| 保德县| 敦煌市| 富川| 彭水| 高尔夫| 电白县| 方城县| 霞浦县| 宜君县| 高密市| 郑州市| 洮南市| 徐闻县| 界首市| 皮山县| 醴陵市| 定兴县| 大荔县| 手游| 潜江市| 精河县| 庆云县| 惠安县| 建始县| 新余市| 阿城市| 安塞县| 怀集县| 晋江市|