Hello,
I'm developing web app where each user have his own database, so I'm creating report datasource in code.
Example:
Dim cnn As New OracleConnection(Session("cnnString").ToString)
Dim sql As String = "SELECT * FROM sometable"
Dim adapter As New OracleDataAdapter(sql, cnn)
Dim table As New DataTable
adapter.Fill(table)
Dim report As New Reports.MyReport
report.DataSource = table
That report have one subreport, but I don't know how to set subreport's datasource in code.
Thanks,
Marin Mašić
I'm developing web app where each user have his own database, so I'm creating report datasource in code.
Example:
Dim cnn As New OracleConnection(Session("cnnString").ToString)
Dim sql As String = "SELECT * FROM sometable"
Dim adapter As New OracleDataAdapter(sql, cnn)
Dim table As New DataTable
adapter.Fill(table)
Dim report As New Reports.MyReport
report.DataSource = table
That report have one subreport, but I don't know how to set subreport's datasource in code.
Thanks,
Marin Mašić
13 Answers, 1 is accepted
0
Hello Milan,
Here is a code to achieve this:
Dim report As New Reports.MyReport
Dim subRepItem1 As Telerik.Reporting.SubReport = TryCast(report.Items.Find("SubReport1", True)(0), Telerik.Reporting.SubReport)
subRepItem1.ReportSource.DataSource = subtable
Hope this helps.
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.
Here is a code to achieve this:
Dim report As New Reports.MyReport
Dim subRepItem1 As Telerik.Reporting.SubReport = TryCast(report.Items.Find("SubReport1", True)(0), Telerik.Reporting.SubReport)
subRepItem1.ReportSource.DataSource = subtable
Hope this helps.
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
Milan
Top achievements
Rank 1
answered on 20 Apr 2009, 11:22 AM
Thank you very much.
0
Brant
Top achievements
Rank 1
answered on 04 Sep 2009, 03:47 PM
I have tried the example code given above in my web app, but the sub report isn't displaying the data in the datatable I am setting to the subreport. I troubleshooted and found there are 4 records for my sub report in the table and the fields match up exactly. Is there a refresh I need to call? Here is my code:
rpt.DataSource = DT
Dim rptSUB As Telerik.Reporting.SubReport = TryCast(rpt.Items.Find("subnApprove", True)(0), Telerik.Reporting.SubReport)
rptSUB.ReportSource.DataSource = DTS
tViewer.Report = rpt
rpt.DataSource = DT
Dim rptSUB As Telerik.Reporting.SubReport = TryCast(rpt.Items.Find("subnApprove", True)(0), Telerik.Reporting.SubReport)
rptSUB.ReportSource.DataSource = DTS
tViewer.Report = rpt
0
Hello Brant,
You can try to see if this resolves it:
tViewer.RefreshReport()
Note that this method has been introduced for the web report viewer in the latest release.
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.
You can try to see if this resolves it:
tViewer.RefreshReport()
Note that this method has been introduced for the web report viewer in the latest release.
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.
0
Brant
Top achievements
Rank 1
answered on 07 Sep 2009, 08:01 PM
I have Telerik Reporting 2008. What do I need to do in my version?
0
Hi Brant,
The RefreshReport() method was introduced because we've changed the way the report is handled by the web report viewer in Q2 2009, however there is no need for such interventions in earlier versions. In fact I've prepared and attached a sample with the latest Q2 SP1 version where it works just fine without a need for refresh.
Kind 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.
The RefreshReport() method was introduced because we've changed the way the report is handled by the web report viewer in Q2 2009, however there is no need for such interventions in earlier versions. In fact I've prepared and attached a sample with the latest Q2 SP1 version where it works just fine without a need for refresh.
Kind 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.
0
Jeff Reinhardt
Top achievements
Rank 1
answered on 12 Oct 2010, 03:57 PM
Attempting to use this solution to set the datasource of my subreport.
Telerik.Reporting.
SubReport subReport = (Telerik.Reporting.
SubReport)report.Items.Find(subReportName, true);
Get this error:
Error 1 Cannot convert type 'Telerik.Reporting.ReportItemBase[]' to 'Telerik.Reporting.SubReport'
0
Hi Jeff,
ReportItemBase[] is an array and you have not specified a member i.e.:
SubReport subReport = (Telerik.Reporting.SubReport)report.Items.Find(subReportName, true)[0];
Additionally if subReportName is the name of the report, you should be using the second overload of the Find method.
Greetings,
Steve
the Telerik team
ReportItemBase[] is an array and you have not specified a member i.e.:
SubReport subReport = (Telerik.Reporting.SubReport)report.Items.Find(subReportName, true)[0];
Additionally if subReportName is the name of the report, you should be using the second overload of the Find method.
Greetings,
Steve
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Jeff Reinhardt
Top achievements
Rank 1
answered on 12 Oct 2010, 07:42 PM
Ok yeah my mistake I somehow left off the array item index. Here is my current state, the report runs, both the report and subreport have the correct data, however, the subreport has no field titles or styling that I have put in on it. Here is a picture.
0
Hi Jeff,
This behavior is by design and noted in the SubReport help article - SubReports' page sections are ignored when the report is used as subreport, as page sections are not related to the report itself, but are relative to the paper or screen i.e. there can only be one page header and one page footer.
In order to simulate header/footer for a subreport that repeats on every page, consider using an unbound group (no grouping criteria specified) and set its GroupHeader/FooterSection.PrintOnEveryPage = True.
Steve
the Telerik team
This behavior is by design and noted in the SubReport help article - SubReports' page sections are ignored when the report is used as subreport, as page sections are not related to the report itself, but are relative to the paper or screen i.e. there can only be one page header and one page footer.
In order to simulate header/footer for a subreport that repeats on every page, consider using an unbound group (no grouping criteria specified) and set its GroupHeader/FooterSection.PrintOnEveryPage = True.
Note that PageCount and PageNumber global objects cannot be accessed in group sections.
All the best,Steve
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Mohamed
Top achievements
Rank 1
answered on 23 Nov 2011, 10:04 PM
thanks for the useful example, in my project i followed the same steps but i'm using two sub reports and when running, both report preview the same data as it seam that they use the same datasource although i'm sure that datatable passed for each sub is diffrent.
any suggestion please ?
any suggestion please ?
0
Hello Mohamed,
There was such a problem in earlier version of the product (Q2 2010-Q3 2010) if I recall correctly. So make sure you're using the latest version of the product and verify that they do indeed get bound to different data. If the issue persists, open a support ticket and provide us with a runnable project and we would advise you accordingly.
Greetings,
Steve
the Telerik team
There was such a problem in earlier version of the product (Q2 2010-Q3 2010) if I recall correctly. So make sure you're using the latest version of the product and verify that they do indeed get bound to different data. If the issue persists, open a support ticket and provide us with a runnable project and we would advise you accordingly.
Greetings,
Steve
the Telerik team
Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!
0
Mohamed
Top achievements
Rank 1
answered on 29 Nov 2011, 07:40 AM
Hi Steve
i'm using Q3 2010, and it seems to be an issue, it's said that it's handled using SP
thanks any way :)
i'm using Q3 2010, and it seems to be an issue, it's said that it's handled using SP
thanks any way :)