This is a migrated thread and some comments may be shown as answers.

Binding to dataset from xml

3 Answers 132 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ingo Dignas
Top achievements
Rank 1
Ingo Dignas asked on 28 May 2009, 11:08 AM
I've following xml file. Each room is a position on a invoice and each room may include multiple optional packages (sub positions). I know I can use the xml to create a dataset and bind it to the control, but how can I define which part of the data to use for the different sections and textboxes? Is there an expression to define table and column or binding a table to a subreport?

<MyOrders>
  <room>
    <roomname>Zimmer</roomname>
    <nr>1</nr>
    <confnumbername>Ihre Reservierungsnummer</confnumbername>
    <confnumber>PL238035928P1<confnumber>
    <selectedroom>Executive Suite</selectedroom>
    <selectedrate>Katalogpreis</selectedrate>
    <ratedes>My rate description</ratedes>
    <details>Anzahl Erwachsener: 2</details>
    <price>480,00</price>
    <curr>EUR</curr>
    <packageinfotxt>Zusätzlich gebuchte Pakete</packageinfotxt>
    <packages>
      <package>
        <packagename>Dünen Beauty</packagename>
        <packagecount>1</packagecount>
        <packageprice>290,00</packageprice>
        <curr>EUR</curr>
      </package>
      <package>
        <packagename>Beauty Arrangement</packagename>
        <packagecount>2</packagecount>
        <packageprice>348,00</packageprice>
        <curr>EUR</curr>
      </package>
    </packages>
  </room>
  <room>
    <roomname>Zimmer</roomname>
    <nr>2</nr>
    <confnumbername>Ihre Reservierungsnummer</confnumbername>
    <confnumber>PL238035928P1<confnumber>
    <selectedroom>Executive Suite</selectedroom>
    <selectedrate>Katalogpreis</selectedrate>
    <ratedes>My rate description</ratedes>
    <details>Anzahl Erwachsener: 2</details>
    <price>480,00</price>
    <curr>EUR</curr>
    <packageinfotxt>Zusätzlich gebuchte Pakete</packageinfotxt>
    <packages>
      <package>
        <packagename>Dünen Beauty</packagename>
        <packagecount>1</packagecount>
        <packageprice>290,00</packageprice>
        <curr>EUR</curr>
      </package>
      <package>
        <packagename>Beauty Arrangement</packagename>
        <packagecount>2</packagecount>
        <packageprice>348,00</packageprice>
        <curr>EUR</curr>
      </package>
    </packages>
  </room>
  <booker>Frau erzet</booker>
  <hotel></hotel>
  <total>1.118,00</total>
</MyOrders>

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 28 May 2009, 11:48 AM
Hello Joerg,

A report can be bound to a single data table only. If you need to present data from more than one, then you can use the Table or Subreport report items i.e. you can bind the report to one datatable report1.DataSource = dataSet1.Table[0]; and bind a subreport or table item to another e.g. dataSet1.Tables[1];

Kind regards,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ingo Dignas
Top achievements
Rank 1
answered on 28 May 2009, 03:37 PM
Hi Steve,

thank you for your answer.
Is it possible to do this:

DataSet

 

myData = new DataSet();

 

 

MemoryStream stream = new MemoryStream(Encoding.GetEncoding("iso-8859-1").GetBytes(xml));

 

 

XmlTextReader reader = new XmlTextReader(stream);

 

myData.ReadXml(reader);

 

this.DataSource = myData.Tables[0];

 

table1.DataSource = myData.Tables[1];

I entered into the table Expressions like this: =[Field.selectedroom]. But when the report get generated I get an error "...is not defined"
But this column exists in Tables[1]

0
Steve
Telerik team
answered on 28 May 2009, 04:03 PM
Hello Joerg,

The expression for a field should be =Fields.SelectedRoom (note the "s"). If you're still getting an error, debug your app and make sure that myData.Tables[0]; and myData.Tables[1]; return proper data.
Also this.DataSource and this.table1.DataSource are correct only if they are used in the report constructor. If you're binding the report and table item in the respective NeedDataSource events, you should use their respective processing items (more info here).

Sincerely yours,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
General Discussions
Asked by
Ingo Dignas
Top achievements
Rank 1
Answers by
Steve
Telerik team
Ingo Dignas
Top achievements
Rank 1
Share this question
or