You can add a new cell DataTableto the cell DataTable. A simple example:
Define a main table with one cell type DataTable:
DataTable people = new DataTable();
people.Columns.Add("Name", typeof(string));
people.Columns.Add("Friends", typeof(DataTable));
Define an auxiliary table:
DataTable friends = new DataTable();
friends.Columns.Add("Name", typeof(string));
friends.Columns.Add("Desire", typeof(string));
Add some data to the subcategory:
friends.Rows.Add("Scarecrow", "brain");
friends.Rows.Add("Tin Woodman", "heart");
friends.Rows.Add("Cowardly Lion", "courage");
Finally, add a row to the main table:
people.Rows.Add("Dorothy", friends);
To get the subtable from the main table, you need to pass the object as DataTable:
DataTable output = (DataTable)people.Rows[0]["Friends"];
source
share