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

ASP.NET 4.5 Report Parameters NULL

3 Answers 205 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 2
Brian asked on 10 Jun 2014, 08:24 PM

Greetings All!
I just started using Telerik Reporting Q1 2014 SP1 (8.0.14.507) and am having a hair-pulling issue regarding report parameters. I have 5 report parameters on the report, and I am passing them values via an ASP.NET 4.5 page just prior to showing the report viewer:

01.protected void Page_Load(object sender, EventArgs e)
02.        {
03.            if (!Page.IsPostBack)
04.            {
05.                // TEMPORARY!!! Only Use For Development if viewing this page directly!!
06.                //Session["REPORT_REPAIR_ID"] = 7;
07. 
08.                if (Session["REPORT_REPAIR_ID"] != null)
09.                {
10.                    TypeReportSource src = new TypeReportSource();
11.                     
12.                    src.TypeName = "Halliburton.DBS.AssetRepairTracker.Reports.RepairOrder, Halliburton.DBS.AssetRepairTracker";
13. 
14.                    src.Parameters.Add(new Telerik.Reporting.Parameter("ReportID", Convert.ToInt32(Session["REPORT_REPAIR_ID"])));
15.                    src.Parameters.Add(new Telerik.Reporting.Parameter("MfgConnection",
16.                                                                        WebConfigurationManager.ConnectionStrings["ManufactureSupport"].ConnectionString));
17.                    src.Parameters.Add(new Telerik.Reporting.Parameter("AssetConnection",
18.                                                                        WebConfigurationManager.ConnectionStrings["AssetRepair"].ConnectionString));
19.                    src.Parameters.Add(new Telerik.Reporting.Parameter("DBProvider", WebConfigurationManager.ConnectionStrings["AssetRepair"].ProviderName));
20.                    src.Parameters.Add(new Telerik.Reporting.Parameter("CryptoKey", this.CryptoKey));
21. 
22.                    this.trvReportViewer.ReportSource = src;
23.                }
24.                else
25.                    throw new Exception("Bad Redirect");
26.            }
27.        }

However when the report is initialized, and I peak at the parameter collection, all the parameters are null (or empty). This is causing an invalid parameter value exception when the parameters validate (because I have AllowNull = false)
(See attached screenshots)




3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 13 Jun 2014, 03:09 PM
Hello Brian,

Based on the provided screenshots we have noticed that you use the report parameters definition counterpart to access the parameter values instead of the processing. It is obligatory to use the report parameters processing counterpart. The definition report parameters value is actually the parameter default value. For more information check out the Using Report Events and Report Life Cycle help article:

For example:

void report_ItemDataBinding(object sender, EventArgs e)
{
    var processingReport = (Telerik.Reporting.Processing.Report)sender;
    var processingParameterValue = processingReport.Parameters["ReportID"].Value;
}

Up to the exception in the first screenshot (aspx-param-value.jpg) you show the value of parameter with key ReportID, however in the other screenshot you are checking the value of RepairID report parameter definition value.

Regards,
Peter
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Brian
Top achievements
Rank 2
answered on 13 Jun 2014, 07:17 PM
Yeah.. I noticed the typo, but when I corrected it the parameters still had no value. When I change it to use the processing instance, everything worked!

There is one last issue I am having, and I am sure it's due to my limited understanding of this tool.. but how do you get the reports processing instance in the constructor? It has no 'sender' to bind (and cast) to..

WIsh I didn't have to hit the ground running on this application. I would have time to play!
0
Accepted
Peter
Telerik team
answered on 18 Jun 2014, 02:07 PM
Hello Brian,

The report processing instance is not accessible in the report constructor because first we have to instantiate the report prior we can process it. For more information see Report Life Cycle. Generally our recommendation is to use expressions and design the reports in a declarative manner without coding and event handling. Check out the expressions and if you need additional assistance please elaborate further on your requirements.

Regards,
Peter
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Brian
Top achievements
Rank 2
Answers by
Peter
Telerik team
Brian
Top achievements
Rank 2
Share this question
or