更新时间:2023-02-14 10:25:43
如果您的CMInfo
是自定义列表,则它希望隐式转换为datatable,
您需要为此付出一些努力.
看一下.
使用泛型和属性从集合到数据表的投射 [ http://beecy.net/post/2009/05/18/convert-generic-list-to-datatable-using-reflection [ http://forums.silverlight.net/forums/p/99187/306445 [ ^ ]
if yourCMInfo
a custom list then it want implicitely convert to datatable,
You need some efforts for this.
Take a Look.
Casting from a Collection to a Data Table using Generics and Attributes[^]
http://beecy.net/post/2009/05/18/convert-generic-list-to-datatable-using-reflection[^]
http://forums.silverlight.net/forums/p/99187/306445[^]
Try this..
public static DataTable ListToDataTable(List<T> mylist)
{
DataTable dt = new DataTable();
dt.Columns.Add("myCol", mylist[0].IntField.GetType());
foreach (MyRecord rc in mylist)
{
dt.Rows.Add(rc.myCol);
}
return dt;
}