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...

Try this Merge option,
ds.Merge(DataSet);

Splitting that two datatables in separate dataset.

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.

Hi,

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

if(firstDataTable.Rows.Count > 0)
{
   //Add all Coulmns and values to 3rd datatable.
   
}

In that same way Add second datatable to third.

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.

<?xml version="1.0" encoding="utf-8"?>
<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">
  <xs:element name="CommonDS">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Table1">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Col1" type="xs:string" />
              <xs:element name="Col2" type="xs:int" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
       
        <xs:element name="Table2">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Column1" type="xs:string" />
              <xs:element name="Column2" type="xs:int" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Pls. Mark as solved if it helps you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.