Click here to Skip to main content
Sign Up to vote bad
good
Dear friends,
 
I have a GridView in which i want data from two different tables. say table1 and table2.
 
I have written a stored procedure which return two tables.
 
Now i want to add this two tables data in one GridView.
 
How can i do that???
 
Thanks in Advance.
Smile | :)
Posted 6-May-12 21:34pm
saj_21945

Comments
Mario Majcica - 7-May-12 3:48am
Are this two tables structurally identical? Are you trying to merge the data between the two? What did you try till now? Make an example.

3 solutions

If thse two tables are similar, you can use a UNION clause.
If they have a foreign key relationship, you could join the two tables and then display them together.
 
Otherwise, I'm not quite sure why you would want to display unrelated data together in a grid.
  Permalink  
Comments
Espen Harlinn - 7-May-12 6:14am
Good idea :-D
add this two tables data in one GridView
One of the ways: Create a new datatable - third one. Add data from first & second to it.
First add columns of datatable 1 & then datatable 2. Next, add data from each tables to this one.
Once done, use the new datatable as a datasource for grid.
 
For a similar schema datatable, use DataTable.Merge Method[^]
  Permalink  
Comments
Espen Harlinn - 7-May-12 6:14am
Good points :-D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Christian Graus 544
1 Michael Haephrati 390
2 OriginalGriff 233
3 Ron Beyer 220
4 samadhan_kshirsagar 219
0 Sergey Alexandrovich Kryukov 6,959
1 Prasad_Kulkarni 3,689
2 OriginalGriff 3,402
3 _Amy 3,332
4 CPallini 2,950


Advertise | Privacy | Mobile
Web03 | 2.6.130617.1 | Last Updated 7 May 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid