Hi all,
I have a DataGridView that is populated by the result of a stored procedure. The stored procedure returns a dataset with two data tables, one being the header and another the data. I populate the datagridview with the second data table. Here is the code:
//Populate the gridview if a dataset was passed
if (cPacket.dReportData != null)
if (cPacket.dReportData.Tables.Count > 0)
{
//The report data is always in the last data table (if more than one).
dvgData.DataSource =
cPacket.dReportData.Tables[cPacket.dReportData.Tables.Count - 1];
//Disable data grid sort behavior.
foreach (DataGridViewColumn column in dvgData.Columns)
{
column.SortMode = DataGridViewColumnSortMode.NotSortable;
}
}
This has worked because all the data that needs to go into the DataGridView has been in one data table.
Now I need to modify the stored procedure and more than one data table will be returned which need to go into the datagridview. I am working to see whether I can combine the sp results into one result set, but no luck so far.
The information that I've found so far assumes that there will be a separate DatGridView for each data table, but in my case, I need to combine all data tables into that one DataGridView.
I found content that describes how to merge two data tables. I am investigating this further to see whether it solves my dilemma:
https://www.c-sharpcorner.com/UploadFile/b182bf/how-to-add-two-datatable-in-single-datatable-in-C-Sharp/
Any recommendations? Thank you! Saga