How can I get the subReport's Uri?

1 Answer 78 Views
General Discussions Report Designer (standalone) Report Parameters
Top achievements
Rank 1
Heejin asked on 19 Apr 2022, 01:19 AM | edited on 20 Apr 2022, 08:24 AM

안녕하세요, 보고서 디자이너에서 subReport를 검색하는 방법으로 CSVDataSource를 사용하고 있습니다. CSVDataSource는 메인 리포트의 ReportParameter를 이용하여 값을 지정하므로 subReport의 ReportSource는 '=Parameters.SubReport Value'가 됩니다. 또한 Telerik에서 제공하는 ReportConnectionStringManager 클래스를 사용하여 소스 코드의 ConnectionString도 변경하려고 합니다. ReportConnectionStringManager 클래스는 SubReport의 ReportSource를 사용하지만 실제 매개변수 값을 가져오지 못하고 '= Parameters.SubReport.Value' 문자열을 가져와서 오류가 발생합니다. 문제를 처리하는 방법을 회신해 주시면 감사하겠습니다. 고맙습니다.


CC :

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 21 Apr 2022, 04:17 PM

Hello Heejin,

I have used a translator to translate the text into English. The English translation that I got from it was the following:

Hi I am using CSVDataSource as a way to retrieve subReport in report designer. Since CSVDataSource specifies a value using ReportParameter of the main report, the ReportSource of subReport becomes '=Parameters.SubReport Value'. I also want to change the ConnectionString in the source code using the ReportConnectionStringManager class provided by Telerik. The ReportConnectionStringManager class uses the SubReport's ReportSource, but it fails to get the actual parameter value, gets the string '= Parameters.SubReport.Value', and throws an error. We appreciate your reply on how to deal with the problem. Thank you.

I have read the English translation but I am not yet sure how are the CsvDataSource and the SubReport related, could you please elaborate further on this via a sample report and a code sample of how the ReportConnectionStringManager is being used? Also, what is the exact error message?

In the SetConnectionString method in the linked article, there is the following code:

            if (item is SubReport)
                    var subReport = (SubReport)item;
                    subReport.ReportSource = this.UpdateReportSource(subReport.ReportSource);

This should be updating the SubReport's ReportSource too without any additional configuration. If there are errors, and the ReportSource of the report is a URI to a file, then it is possible that the path, where this code is being run, is being messed up since the URI to the SubReport report is probably relative.

To get the URI of the SubReport.ReportSource, you can cast it to UriReportSource, then its Uri property will have the URI, for example:

                    var subReport = (SubReport)item;
                    var urs = (UriReportSource)subReport.ReportSource;
                    var subReportUri = urs.Uri;

If further assistance is needed, please attach a runnable project that demonstrates the problem.

Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at
Top achievements
Rank 1
commented on 22 Apr 2022, 01:38 AM

Hello thank you for your reply.
I attached the report file I made.

According to the attached report file, the report source of subReport1 is '= Parameters.SubReport1.Value'.

Due to the issue, running the source below causes an error by returning '= Parameters.SubReport1.Value' instead of the uri value.


[Source Code]

Dim source As New Telerik.Reporting.UriReportSource()
source.Uri = "Report2.trdx"
source.Parameters.Add(New Telerik.Reporting.Parameter("SubReport1", "Report/Report2_sub.trdx"))
source.Parameters.Add(New Telerik.Reporting.Parameter("org_code", "KR"))

Dim connectionStringHandler = New ReportConnectionStringManager(gConnectionString)
Dim reportSource = connectionStringHandler.UpdateReportSource(source)

ft.ReportViewer1.ReportSource = reportSource



' Public Sub SetConnectionString(reportItemBase As ReportItemBase) syncopation
If TypeOf item Is SubReport Then
                Dim subReport = DirectCast(item, SubReport)
                subReport.ReportSource = Me.UpdateReportSource(subReport.ReportSource)
                Continue For
End If
' Public Function UpdateReportSource(sourceReportSource As ReportSource) As ReportSource syncopation
Dim reportInstance = DeserializeReport(uriReportSource)
Public Function DeserializeReport(uriReportSource As UriReportSource) As Report
        Dim settings = New System.Xml.XmlReaderSettings()
        settings.IgnoreWhitespace = True
        Using xmlReader = System.Xml.XmlReader.Create(uriReportSource.Uri, settings)
            Dim xmlSerializer = New Telerik.Reporting.XmlSerialization.ReportXmlSerializer()
            Dim report = DirectCast(xmlSerializer.Deserialize(xmlReader), Telerik.Reporting.Report)
            Return report
        End Using
End Function

[Error Image]

(='File not found.')


'= Parameters.SubReport1.Value' is the Report Parmater, and this Parameter value indicates CSVDataSource . CSVDataSource has the filename of SubReport registered.
 ex) Report/Report2_sub.trdx

My intention is to prevent the error by having 'Report /Report2_sub.trdx' returned instead of '= Parameters.SubReport1.Value'.
 I'd be appreciated if your reply consists of a way to solve the problem.

Thank you.



Telerik team
commented on 26 Apr 2022, 03:41 PM

Thank you for clarifying what was the issue!

The problem is that when you deserialize the report, the runtime value of the Parameter.SubReport1.Value expression will not yet be evaluated. This value will be evaluated at runtime when the engine processes and then renders the report.

For the reason listed above, you cannot get the evaluated value from the report parameter. What you can instead do, is you can attempt to find the CSV data source from the main report and you can then try to read the path from it in your methods. To retrieve the CsvDataSource from the main report, you can call the Report.GetDataSources Method to search for the data source of type CsvDataSource. Calling this on the main report will get you the csvDS data source component and in the Source property, you will have the path values that you can then use to Deserialize those reports.

In case that is not an option, you can embed the reports in the SubReport items as XML markup, then the SubReport's ReportSource will be an XmlReportSource to which you can directly edit the report connection string through the XmlReportSource.Xml Property.

Let me know if you have any other questions.

General Discussions Report Designer (standalone) Report Parameters
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question