Merging data in a datagridview

I am building a web page that will be presenting users two dataset results from two stored procedures in sql but the data is not similar. Is it possible to present both datasets to users in one datagridview? I am unable to do a union of the data in SQL due to the fact that the results aren’t similar and wanted to see if I could work around this issue with .net.

Thank you


This might help you. Of course you are going to have to add the other logic to the code to fit your needs.

Merging two Datasets into a single Datagrid: ASP Alliance

At least it will get you in the right direction. Just focus on the “Merge()” method of the DataSet.

Good Luck


I’ve looked at that information and the thing that I immediately notice is this list of “conditions” that they talk about:

  1. All the columns specified in the datagrid must be present in both datasets.
  2. The data type of all columns in the datasets must be the same.
  3. The column names should match.

In my post, I did make mention of the fact that my data is dissimilar and that they don’t match. I know that you can merge like data, but what I want to know is if you can merge unlike data.

Have you tried looping through your data sets? I’ve tried that in If i can’t come up with the desired output using one stored procedure, what I do is try to assign field values from both data sets (output of stored procedures) to each corresponding grid cell. This MIGHT require 2 loops (or two counters) since you have 2 data sets.

datagrid.Rows(i).Cells(0).Value = dataset1.GetInt32(0)
dg.Rows(i).Cells(1).Value = dataset2.GetInt32(0)

This can work if you have with a small amount of data only (few resulting rows).