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

ReportParameters from WebApp not being passed to Report Class

1 Answer 61 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Erik
Top achievements
Rank 1
Erik asked on 07 Nov 2011, 01:43 PM
Hello everyone,

I am trying to pass some ReportParameters to a report class that I´ve created.

I´ve got the following set up:

Created Report Class as per Telerik best practices.
Created 2 parameters. one called CMU the other AlarmType.

On .net web app, I´ve got a set of drop down lists that should be used to filter the info required.

I´ve got a ReportViewer1 that calls the "Reporting" class.

On my code behind, I´ve got the following:

Dim Report As Telerik.Reporting.Report
Report = New RDC_Reporting.reporting
 
 Report.ReportParameters.Item("CMU").Value = cmu_instances.SelectedItem.Text
Report.ReportParameters.Item("AlarmType").Value = "YELLOW"
 
ReportViewer1.RefreshReport()

The ReportParameters in my Report class are set to not accept null, so that i know If the value is being passed or not.

In my web app, the given values ARE accepted apparently, as no error is being thrown at the moment the values are fed, however, when the Report regenerates, it says "

Invalid value of report parameter 'CMU'.


If i set the paramter to accept null values, it simply shows the report, but with no results.

Any help?

1 Answer, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 08 Nov 2011, 04:47 PM
Hello Erik,

I assume that the code you provided is from a method that handles some sort of event (ButtonClick or dropDownList_SelectionChanged)
In this case you are assigning parameter values to a new Report, probably not the one that your ReportViewer displays. You only need to create the report itself once in the page constructor.
Here is how you can get the report from your viewer and modify its properties:

Dim report As ReportLibrary.MyReport         
report = ReportViewer1.Report   'get the report from the viewer             

Afterwards you can assign the values and refresh the report.
You can also set initial values to the ReportParameters from inside the report to avoid getting the error at first page load (before first specifying parameters).
Note you should also check if the Type of the parameter matches the value you are trying to assign to it.

Regards,
Elian
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

Tags
General Discussions
Asked by
Erik
Top achievements
Rank 1
Answers by
Elian
Telerik team
Share this question
or