list<object>转换成datatable
List<object>是一个集合,有很多列,现在我想要把把所有的列都存放在一个dataTable中,我搞了很久,就是转换不成功。不知道怎么的。请各位帮忙解决。现在分少,...
List<object> 是一个集合,有很多列,现在我想要把把所有的列都存放在一个dataTable中,我搞了很久,就是转换不成功。不知道怎么的。请各位帮忙解决。现在分少,等成功之后,可以加。谢谢各位朋友。
自己解决了参考一下
List<object> list = new List<object>();
list=gvGoods.GetSelectedFieldValues("GOODSCODE", "GOODSNAME", "MODEL", "UPC", "PRICE", "RETAILPRICE", "WHOLESALEPRICE", "SALESPRICE");
DataTable dt=new DataTable();
dt.Columns.Add("GOODSCODE");
dt.Columns.Add("GOODSNAME");
for (int i = 0; i < list.Count; i++)
{
DataRow dr = dt.NewRow();
dr["GOODSCODE"] = this.gvGoods.GetRowValues(i, new string[] { "GOODSCODE" });
dr["GOODSNAME"] = this.gvGoods.GetRowValues(i, new string[] { "GOODSNAME" });
dt.Rows.Add(dr);
} 展开
自己解决了参考一下
List<object> list = new List<object>();
list=gvGoods.GetSelectedFieldValues("GOODSCODE", "GOODSNAME", "MODEL", "UPC", "PRICE", "RETAILPRICE", "WHOLESALEPRICE", "SALESPRICE");
DataTable dt=new DataTable();
dt.Columns.Add("GOODSCODE");
dt.Columns.Add("GOODSNAME");
for (int i = 0; i < list.Count; i++)
{
DataRow dr = dt.NewRow();
dr["GOODSCODE"] = this.gvGoods.GetRowValues(i, new string[] { "GOODSCODE" });
dr["GOODSNAME"] = this.gvGoods.GetRowValues(i, new string[] { "GOODSNAME" });
dt.Rows.Add(dr);
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询