-2
public DataTable LoadPaymentsList()
{
List<DataTable> lstDts = new List<DataTable>();
// Copy into dt
Datatable dt=new Datatable();
return dt;
}
public DataTable LoadPaymentsList()
{
List<DataTable> lstDts = new List<DataTable>();
// Copy into dt
Datatable dt=new Datatable();
return dt;
}
我不認爲還有比簡單一個更好的方式 - 和Column
-Adding:
DataTable mergedTable = new DataTable();
List<DataTable> tableCollection = new List<DataTable>();
/*---------------------------------*/
bool columnsAdded = false;
foreach (DataTable table in tableCollection)
{
if (!columnsAdded)
{
foreach (DataColumn column in table.Columns)
{
mergedTable.Columns.Add(column);
}
columnsAdded = true;
}
foreach (DataRow row in table.Rows)
{
mergedTable.Rows.Add(row);
}
}
你想看看合併表。檢查數據表合併的進一步信息,http://www.c-sharpcorner.com/UploadFile/0c1bb2/merging-multiple-datatables-into-single-datatable-using-asp/
//merging first data table into second data table
dt2.Merge(dt);
dt2.AcceptChanges();
這些表是否包含相同的列?如何填充'lstDts'? –
是的,所有的列名都是相同的。對於填充lstDts我已經完成了這個代碼 –