原理不多说了,就是clone一个Table,然后循环插入
/// <summary> /// 转换DataView至DataTable /// </summary> /// <param name="dv">要处理的DataView</param> /// <param name="tableName">DataTable的名称</param> /// <returns></returns> public DataTable DataViewToDataTable(DataView dv,string tableName="Table") { //Clone dv.Table to dtTemp DataTable dtTemp = dv.Table.Clone(); dtTemp.TableName = tableName; foreach (DataRowView drv in dv) dtTemp.ImportRow(drv.Row); return dtTemp; }

微信扫码查看本文
发表评论