How to rearrange datacolumns in a dataset from related datatables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sri13
    New Member
    • Sep 2010
    • 11

    How to rearrange datacolumns in a dataset from related datatables

    Hi

    I have 3 tables related by some keys. I add these three tables to a dataset and finally write to XML file. The XML file is then sent to the client. Since I added the relations, the XML shows proper hierarchy. I am facing an issue that the XML file shows the related data in sequencial order. Ex:
    Code:
    <table1>
      <table1_col1>col1</table1_col1>
      <table1_col2>col2</table1_col2>
      <table1_col3>col3</table1_col3>
      <table2>
        <table2_col1>col1</table2_col1>
        <table2_col2>col2</table2_col2>
        <table3>
              <table3_col1>col1</table3_col1>
        </table3>
      </table2>
    </table1>
    But actually, I want to see the output as:
    Code:
    <table1>
      <table1_col1>col1</table1_col1>
      <table2>
        <table2_col1>col1</table2_col1>
        <table2_col2>col2</table2_col2>
        <table3>
              <table3_col1>col1</table3_col1>
        </table3>
      </table2>
      <table1_col2>col2</table1_col2>
      <table1_col3>col3</table1_col3>
    </table1>
    I am creating each databale dynamically and add the relations and tables to the dataset. And then call WriteXML to create the output. I am not sure if I can use SetOrdinal to arrange the entire datatable? Please help.
Working...