Can a data-related cell contain data?

If you do not use any structure?

+3
source share
4 answers

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"];
+4
source

DataSet . .

WriteXml ReadXml .

1: . 1: JavaScript, ?

+2

, , / DataRelation. , , - xml - .

+1

, , - :

DataRow dr = new DataRow();
DataTable dtable = dr[0].Table

MSDN: DataRow DataTable : DataTable, .

Example and explanation: http://msdn.microsoft.com/en-us/library/system.data.datarow.table.aspx

0
source

Source: https://habr.com/ru/post/1717091/


All Articles