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

Silverlight ReportViewer - Cannot pass parameter to report in the latest version 8.2.14.1204

3 Answers 70 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sherwin
Top achievements
Rank 1
Sherwin asked on 18 Dec 2014, 03:40 PM
Hi,

We have a Silverlight application and we recently updated to use the latest Telerik UI and Reporting. However, we encountered some issues when passing parameter to the report. It seems that with the latest update of Telerik Reporting, the report cannot capture the parameters passed from ReportViewer. I was able to reproduce the issue in the Telerik Report Examples by changing the following:

1. In MainPage of CSharp.SilverlightDemo project, I've added the ApplyParameters event:

<telerik:ReportViewer Grid.Row="1" x:Name="ReportViewer1" Width="1000" ReportServiceUri="../ReportService.svc"
Report="Telerik.Reporting.Examples.CSharp.ReportCatalog, CSharp.ReportLibrary"
ApplyParameters="ReportViewer1_OnApplyParameters"/>

private void ReportViewer1_OnApplyParameters(object sender, ApplyParametersEventArgs args)
{
  args.ParameterValues["Test1"] = "Test1";
  args.ParameterValues["Test2"] = "Test2";
}

2. In ReportCatalog.cs of CSharp.ReportLibrary project, I've added the following:

public ReportCatalog()
{
//
// Required for telerik Reporting designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
ReportParameters.Add(new ReportParameter { Name = "Test1", Type = ReportParameterType.String });
ReportParameters.Add(new ReportParameter { Name = "Test2", Type = ReportParameterType.String });
ItemDataBinding += ReportCatalog_ItemDataBinding;
}

void ReportCatalog_ItemDataBinding(object sender, System.EventArgs e)
{
var test1 = ReportParameters["Test1"].Value;
var test2 = ReportParameters["Test2"].Value;
textBox4.Value = test1 != null ? test1.ToString() : "Test1 null";
textBox8.Value = test2 != null ? test2.ToString() : "Test2 null";
}

When I run the application, I was not getting the values of Test1 and Test2 parameters. This approach works in the previous version of Telerik Reporting.

Can you take a look why it is not working the latest version anymore and advise if there is another way to accomplish this?

Thanks,
Sherwin

3 Answers, 1 is accepted

Sort by
0
Sherwin
Top achievements
Rank 1
answered on 19 Dec 2014, 04:02 PM
Just an additional info, it used to work on build Q2 2012 SP1 and it stopped working on Q3 2012 SP1 (6.2.13.110) build.
0
Accepted
Hinata
Top achievements
Rank 1
answered on 23 Dec 2014, 08:07 AM
Hi Sherwin,

Using an event to set some text box values in your report is probably the main issue here.
It is not recommended to use events in your reports. This is often mentioned by Telerik staff in the forums and in their help: http://www.telerik.com/help/reporting/report-events.html (the first line).
Also you are not doing it correctly, because you are accessing the report items by their definition inside an event and you should be accessing the processing items. There is a difference explained here: http://www.telerik.com/help/reporting/designing-reports-life-cycle.html
and also here: http://www.telerik.com/help/reporting/faq-accessing-items.html.
0
Sherwin
Top achievements
Rank 1
answered on 23 Dec 2014, 03:24 PM
Thank you Hardik for the insight. That helped me to solve my issue.
Tags
General Discussions
Asked by
Sherwin
Top achievements
Rank 1
Answers by
Sherwin
Top achievements
Rank 1
Hinata
Top achievements
Rank 1
Share this question
or