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

Creating Report Using XML Data

1 Answer 84 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
David Copp
Top achievements
Rank 1
David Copp asked on 27 Jan 2010, 07:32 PM

I am converting some Crystal Reports to telerik reporting.  We use XML that is stored in a database as the datasource and already use the readxml method to load a dataset.  That works fine.  I am using the following code to instantiate the report viewer, I got this from the samples included with the trial download.  It works and I get the report on screen.  My problem is that I don't find a 'DataSource' property suggested in option 2 of a previous thread on any of the objects below in which to assign my dataset.  I'm sure that I'm missing something simple, but have looked for several hours and haven't found it.  Can you help?

Dim reportName As String = Server.UrlDecode(sReportName.ToString)   
 
If Not String.IsNullOrEmpty(reportName) Then   
 
    Dim reportType As TypeType = Type.[GetType](reportName)   
    Dim report As IReportDocument = DirectCast(Activator.CreateInstance(reportType), IReportDocument)   
 
    Me.ReportViewer1.Report = report   
 
    Me.Page.Title = "Reports - " + ReportTitle.ToString   
   
End If  
 
 

 


 

1 Answer, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 28 Jan 2010, 02:42 PM
Hi David Copp,

That is because IReportDocument does not have a DataSource property, only the Report has a DataSource. We have used IReportDocument in our demo reports as one of the examples is a ReportBook and thus it requires the usage of that interface and we do not set DataSource from the calling application.
Anyway you do not need to use that code (which is that complicated as we did not want to hardcode each of the reports available in the classlibrary) for setting a single report to show in the viewer. A code like below is sufficient:

Dim report As Telerik.Reporting.Report = New MyReport()
ReportViewer1.Report = report

Regards,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
David Copp
Top achievements
Rank 1
Answers by
Steve
Telerik team
Share this question
or