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

4 posts, 1 answers
  1. Sherwin
    Sherwin avatar
    22 posts
    Member since:
    Jan 2011

    Posted 18 Dec 2014 Link to this post

    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

  2. Sherwin
    Sherwin avatar
    22 posts
    Member since:
    Jan 2011

    Posted 19 Dec 2014 Link to this post

    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.
  3. Answer
    Hinata
    Hinata avatar
    146 posts
    Member since:
    Dec 2013

    Posted 23 Dec 2014 in reply to Sherwin Link to this post

    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.
  4. Sherwin
    Sherwin avatar
    22 posts
    Member since:
    Jan 2011

    Posted 23 Dec 2014 in reply to Hinata Link to this post

    Thank you Hardik for the insight. That helped me to solve my issue.
Back to Top