944,142 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 1682
  • ASP.NET RSS
Oct 14th, 2009
0

How to combine two tables into a single datagrid

Expand Post »
Hi,

I have a dataset which is having 5 tables. I want to get only two tables from that dataset and assign into a single datagrid. How can i do this?

Thanks in advance...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sanjanaa is offline Offline
6 posts
since Oct 2009
Oct 14th, 2009
0
Re: How to combine two tables into a single datagrid
Try this Merge option,
ds.Merge(DataSet);

Splitting that two datatables in separate dataset.
Reputation Points: 9
Solved Threads: 13
Junior Poster in Training
chandru7 is offline Offline
72 posts
since Sep 2009
Oct 19th, 2009
0
Re: How to combine two tables into a single datagrid
Hi Chandru, Thank you very much for your kind reply. I did that method, but in that my problem is, i have 3 rows, 8 columns in table1 and 3 rows, 8 columns in table2. First 2 columns of both the tables are same. Always i will get row count is same for both the tables. So, if i use this merge method then it creates a table with 6 rows, and also after the 8th columns has no values in first 3 rows and first 8 columns has empty values in second 3 rows.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sanjanaa is offline Offline
6 posts
since Oct 2009
Oct 19th, 2009
1
Re: How to combine two tables into a single datagrid
Hi,

i will work if both structure's or same.For different structure just try like this,

ASP.NET Syntax (Toggle Plain Text)
  1. if(firstDataTable.Rows.Count > 0)
  2. {
  3. //Add all Coulmns and values to 3rd datatable.
  4.  
  5. }

In that same way Add second datatable to third.
Last edited by peter_budo; Oct 24th, 2009 at 6:17 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
Reputation Points: 9
Solved Threads: 13
Junior Poster in Training
chandru7 is offline Offline
72 posts
since Sep 2009
Oct 19th, 2009
0
Re: How to combine two tables into a single datagrid
Hello there

If i understand u correctly, u need a Nested/group dataset in a single dataset

Do the following, i have created an eg for you.
follow the steps
1) In solution explorer Add-> new Items -> Select "XML Schema"
2) Give the name eg : CommonDS Set
3) Go to the properities of "CommonDS" and Change Custom tool Property: MsDataSetGenerator
4) Right Click CommonDS -> View Code
5) Paste the following code Then change the Table NAme & Column names as per your requirement.
ASP.NET Syntax (Toggle Plain Text)
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xs:schema id="CommonDS" targetNamespace="http://tempuri.org/CommonDS.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/CommonDS.xsd" xmlns:mstns="http://tempuri.org/CommonDS.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  3. <xs:element name="CommonDS">
  4. <xs:complexType>
  5. <xs:sequence>
  6. <xs:element name="Table1">
  7. <xs:complexType>
  8. <xs:sequence>
  9. <xs:element name="Col1" type="xs:string" />
  10. <xs:element name="Col2" type="xs:int" />
  11. </xs:sequence>
  12. </xs:complexType>
  13. </xs:element>
  14.  
  15. <xs:element name="Table2">
  16. <xs:complexType>
  17. <xs:sequence>
  18. <xs:element name="Column1" type="xs:string" />
  19. <xs:element name="Column2" type="xs:int" />
  20. </xs:sequence>
  21. </xs:complexType>
  22. </xs:element>
  23.  
  24. </xs:sequence>
  25. </xs:complexType>
  26. </xs:element>
  27. </xs:schema>

Pls. Mark as solved if it helps you
Reputation Points: 12
Solved Threads: 38
Junior Poster
reach_yousuf is offline Offline
194 posts
since Sep 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: calling javascript after databse validation??
Next Thread in ASP.NET Forum Timeline: thumbnails for flv





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC