I have a dataset with dozens of tables. Each table has only a few rows of data. I would like to combine all the rows from each table (somehow) and display them in a DataGridView.
Here is what I tried, but I get an error (see comments in code):
DataSet ds = new DataSet();
ds = Fill(); // dataset it filled with Tables (only a few rows per table). Fill() method not included for brevity.
DataSet combinedDataSet = new DataSet();
for (int i = 0; i < ds.Tables.Count; i++ )
DataRow newRow = combinedDataSet.Tables.NewRow(); // <-- error: "cannot find table 0."
newRow = ds.Tables[i].Rows;
//dataGridView1.DataSource = ds.Tables.Rows; // however, this works (shows me one row in dataGridView1)
dataGridView1.DataSource = combinedDataSet.Tables;
This is strange to me because I can definitely see table 0 in the dataGridView1 (see comment above). But, if I try to merge them together I get an error (see comment above).
Any chance you know how to handle this problem?
Many thanks in advance!