SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

    Doug

  2. #2
    SitePoint Guru Jason__C's Avatar
    Join Date
    Oct 2009
    Location
    Racoon City
    Posts
    660
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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

  3. #3
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    USP,

    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.

  4. #4
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried looping through your data sets? I've tried that in visual.net. 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).


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •