A
{
public TableForXML()
{
TRows = new List<TRow>();
}
public List<TRow> TRows { get; set; }
public TableForXML ConvertDataTAble(DataTable dataTable)
{
TRow rowHead = new TRow();
foreach (DataColumn columnTable in dataTable.Columns)
{
rowHead.TCells.Add(columnTable.ColumnName);
}
TRows.Add(rowHead);
foreach (DataRow rowTable in dataTable.Rows)
{
TRow row = new TRow();
var cells = rowTable.ItemArray;
foreach (object cell in cells)
row.TCells.Add(cell.ToString());
TRows.Add(row);
}
return this;
}
}
[Serializable]
public class TRow
{
public TRow()
{
TCells = new List<string>();
}
public List<string> TCells { get; set; }
}