标签:ack har blog content 数据格式 格式化 null tty static
代码例如以下
public static List<SelectListItem> CreateSelect<T>(this IList<T> t, string text, string value)
{
List<SelectListItem> l = new List<SelectListItem>();
foreach (var item in t)
{
var propers = item.GetType().GetProperty(text);
var valpropers = item.GetType().GetProperty(value);
l.Add( new SelectListItem{Text=propers.GetValue(item,null).ToString(), Value=valpropers.GetValue(item,null).ToString()} );
}
return l;
}
c#List泛型数据扩展,把List<>型数据格式化成List<SelectListItem>,用来作dropdownlist的数据
标签:ack har blog content 数据格式 格式化 null tty static
原文地址:http://www.cnblogs.com/zhchoutai/p/7193675.html