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

WebService as DataSource

4 Answers 470 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 2
James asked on 05 Nov 2008, 06:12 PM
Here is my setup.
I have a webpage that contains a viewer.  When a user request this page, the code will call a web service. This webservice contains many classes that each contain data that needs to be shown on the web page, so I have the code creating a datatable from the specific fields I need for the report.  I then want to set the report's datasource to this datatable.  Currently it is only showing 2 records, and the report is created with 2 records, but no data is visible in the fields.

Here is the code from the page.load event for the page containing the report viewer:
            Me.CreatePickTicketColumns()  
            Me.GetPickTickets()  
 
            Dim subRpt As Telerik.Reporting.Report = New TelerikReports.PickTicketDetail  
            Dim mainRpt As Telerik.Reporting.Report = New TelerikReports.PickTicket  
 
            mainRpt.DataSource = Me._dtPickTicketHdr  
            Me.ReportViewer1.Report = mainRpt 

The GetPickTickets method is calling the web service and adding rows with specific data to the datatable that is getting set as the datasource for the main report.  The web service call will also create the datatable for the subreport but I haven't coded that yet since I cannot get the header data to display yet.

I can send the project since it is quite small but you probably would not have access to the webservice.

Thanks. 

4 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 07 Nov 2008, 03:18 PM
Hello James,

Telerik.Reporting is not aware and neither does it matter to it, where the data is coming from. In this line of thoughts I've created a sample app to show you the desired behavior - instead of webservice, I've used a static datatable.

Kind regards,
Steve
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
James
Top achievements
Rank 2
answered on 07 Nov 2008, 04:18 PM

Steve,
Exactly what I came up with, and thanks for confirming my solution!

 

I have run into another roadblock with completing this report.  The code sample I provided in the first post had a subreport that I hadn't loaded the data for yet, but good news, I got that working also.

 

The roadblock is the subreport of the subreport.  I cannot get the datasource for it set correctly.  Here is what the code looks like in my attempt to set the datasource for the subreport of the subreport of the mainreport.

'This code is from the Default page that contains the report viewer:  
   mainRpt.DataSource = Me._dsPickTicket  
   mainRpt.DataMember = "PickTicketHeader" 
   objPickTicket.DataSourceOfSubReport1 = Me._dsPickTicket  
   objPickTicket.DataMemberOfSubReport1 = "PickTicketDetail" 
 
   Dim subRptItemDtl As Report = New TelerikReports.PickTicketDetail()  
   Dim objPickTicketDtl As PickTicketDetail = subRptItemDtl  
   objPickTicketDtl.DataSourcePickTicketBins = Me._dsPickTicket  
   objPickTicketDtl.DataMemberPickTicketBins = "PickTicketBins" 
 
   Me.ReportViewer1.Report = mainRpt  
 
 
'This code is from the MainReport code-behind to set the subreport1 datasource  
    Public WriteOnly Property DataSourceOfSubReport1() As DataSet  
        Set(ByVal value As DataSet)  
            Me.srPickTicketDtls.ReportSource.DataSource = value  
        End Set 
    End Property 
    Public WriteOnly Property DataMemberOfSubReport1() As String 
        Set(ByVal value As String)  
            Me.srPickTicketDtls.ReportSource.DataMember = value  
        End Set 
    End Property 
 
 
'This code is from the SubReport of the MainReport code-behind to set the subreport of the subreport2 datasource  
    Public WriteOnly Property DataSourcePickTicketBins() As DataSet  
        Set(ByVal value As DataSet)  
            Me.srPickTicketBins.ReportSource.DataSource = value  
        End Set 
    End Property 
 
    Public WriteOnly Property DataMemberPickTicketBins() As String 
        Set(ByVal value As String)  
            Me.srPickTicketBins.ReportSource.DataMember = value  
        End Set 
    End Property 
 
 
 
 

Another issue is when I attempt to apply filtering for the records in the first subreport, the one on the mainreport.  I followed the example in the Report Documention for creating master-detail reports, but I only get on the records when I do this.

Thanks in advance for your help!
0
Accepted
Steve
Telerik team
answered on 11 Nov 2008, 02:07 PM
Hi James,

I've already answered your inquiry in the ticket your colleague has opened but will post it here as well, in case somebody else is wondering. For nested subreport-subreport scenario, you can directly find the subreport items and access them without exposing public properties as this gets confusing when used for nested items. i.e.:

   Me.ReportViewer1.Report = New Report1() 
        'find the subreport item 1 
        Dim subRepItem1 As Telerik.Reporting.SubReport = TryCast(ReportViewer1.Report.Items.Find("SubReport1"True)(0), Telerik.Reporting.SubReport) 
        ' find the subreport item 2 
        Dim subRepItem2 As Telerik.Reporting.SubReport = TryCast(subRepItem1.ReportSource.Items.Find("SubReport2"True)(0), Telerik.Reporting.SubReport) 
        ' set datasource for the reports 
        TryCast(Me.ReportViewer1.Report, Report1).DataSource = Me.GenerateDummyDataSource() 
        TryCast(subRepItem1.ReportSource, SubReport1).DataSource = Me.GenerateDummyDataSource() 
        TryCast(subRepItem2.ReportSource, SubReport2).DataSource = Me.GenerateDummyDataSource() 
        'same thing for more nested subreports 

Find attached a sample app showing this functionality at hand. Give it a spin and let us know how it goes.

Best wishes,
Steve
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
James
Top achievements
Rank 2
answered on 11 Nov 2008, 02:37 PM

Steve,
The colleague is me, and I appreciate the response on the ticket and here also.  The solution (sample) is exactly what I was looking for.

Thanks very much for your help!

Tags
General Discussions
Asked by
James
Top achievements
Rank 2
Answers by
Steve
Telerik team
James
Top achievements
Rank 2
Share this question
or