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

XML DataSource from a field in SQL DataSource

1 Answer 142 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Derek
Top achievements
Rank 1
Derek asked on 24 Oct 2012, 06:07 PM
What I want to do is pull a field from SQL that contains XML, parse that XML into a class, then use that as my object data source.
I have sqlDataSource1 that will get the text (XML) field from the DB using my ReportParameter (so it only gets 1 record).
I also have objectDataSource1 that will display the data from my class.
Right now objectDataSource 1 is the Report's datasource.

I also have a NeedDataSource event trigger on the report.

The question is "Can I have the event trigger tell the sqlDataSource1 to go get the data, parse it, then feed it to objectDataSource1 to display on the report?"

This sample shows how to read in an xml file, parse it, then feed it to data source to display.  So I imagine I should be able to do it.  Does someone do the same thing?  Am I going about it the hard way?

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 25 Oct 2012, 01:24 PM
Hi Derek,

The ReportItem.DataObject expression references the parent's data item data. In this line of thoughts the ReportItem.DataObject.MyField retrieves the MyField from the parent data item (table, report) datasource. Thus our suggestion is to use datasource components relations capability. For example when SqlDataSource1 is set to the report and ObjectDataSource1 is set to a table nested in the report. You can set ObjectDataSource1 datasource parameter to a SqlDataSource1 field as shown in the following example:

 Name

 Type

Value 

 @MyField

String

= ReportItem.DataObject.MyField

This way you can retrieve the XML in your data layer to parse it and return the appropriate data for data binding the table item.

Kind regards,
Peter
the Telerik team

HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

Tags
General Discussions
Asked by
Derek
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or