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

Grouping and ReportParameter issues after upgrade to Q2 2013 SP1

6 Answers 100 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Robert Michels
Top achievements
Rank 1
Robert Michels asked on 27 Aug 2013, 02:32 PM
Hi, we are having 2 issues after upgrading from Telerik Reporting Q3 2012 to Q2 2013 SP1.

1) We are programmatically changing the grouping in the NeedDataSource event for a report. In the event, the Telerik.Reporting.Group now returns null when the report is run and throws a NullReferenceException when accessed. Here is the code that works ok in Q3 2012 but fails in Q2 2013 SP1.  The code compiles ok but fails on the first line with a NullReferenceException.  Should we still be able to access the Group in this way?

group1.Groupings.Clear();
 
if (intervalGroup == "HalfHour")
{
    group1.Groupings.AddRange(new Telerik.Reporting.Grouping[] {
            new Telerik.Reporting.Grouping("=dIntervalStart")
        });
    txtIntervalGroupLabel.Value = "=dIntervalStart";
    txtIntervalGroupLabel.Format = "{0:g}";
}
else
{
    group1.Groupings.AddRange(new Telerik.Reporting.Grouping[] {
           new Telerik.Reporting.Grouping("=dIntervalStart.Date")
        });
 
    txtIntervalGroupLabel.Value = "=dIntervalStart.Date";
    txtIntervalGroupLabel.Format = "{0:d}";
}


2) We also need to access the values of ReportParameters in the NeedDataSource event.  Accessing the ReportParameterCollection directly using the following syntax returns null for the parameter value after the upgrade to Q2 2013 SP1 but worked fine in Q3 2012:

string intervalGroup = ReportParameters["IntervalGroup"].Value.ToString();

We do have success accessing the parameter values by using the processing instance and then the Parameters property of that object:

Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;
string intervalGroup = report.Parameters["IntervalGroup"].Value.ToString();

I just wanted to make sure that accessing the values of parameters through ReportParameters directly has been deprecated or made obsolete. Can you provide any info on this?

Thanks!

6 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 27 Aug 2013, 04:55 PM
Your null reference exception is probably caused by your .ToString() instruction.  You cannot .ToString a null value.  Perform a test for null and if not null then do a ToString.  Bear in mind that you might get DBNull.Value or Null.
0
Robert Michels
Top achievements
Rank 1
answered on 27 Aug 2013, 06:44 PM
Thanks David,

That may be an issue in some cases, but we are experiencing an issue when a report parameter with a specified key does actually have a value and should not be null (unless ReportParameters has changed, which is what I am asking).

Previously, we were able to use ReportParameters["key"] to retrieve the value in NeedDataSource, but now it is null, while report.Parameters["key"] will have the non-null, correct parameter value. Did this change in a recent version?
0
David
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 27 Aug 2013, 06:52 PM
I personally have never needed to use the "NeedDataSource" event from a report.  I use it extensively with other controls.  All my reports are databound at the time of report creation (along with all sub-reports).

Based upon online documentation however it looks like the usage of parameters in the NeedDataSource is still supported.  Perhaps your NULL values are question of timing?  I.E,, load versus databinding???

http://www.telerik.com/help/reporting/designing-reports-parameters-programmatic-control.html

0
Robert Michels
Top achievements
Rank 1
answered on 27 Aug 2013, 07:09 PM
Yes, programmatic access to report parameters in NeedDataSource is still available through obtaining a processing instance of the report and using report.Parameters["key"]. I just wanted to see if no longer being able to access the values through ReportParameters["key"] is due to some deprecation or if it is a bug.

We have over 25 reports and changing all of the calls in the NeedDataSource events and other databinding events is tedious.

As an aside, we are able to SET parameter values (and availablevalues) using ReportParameters["key"] before report execution, but they return null on report execution as we are indicating.
0
Xiufeng
Top achievements
Rank 1
answered on 05 Sep 2013, 08:34 PM
Hi,

Have you fixed this issue? We have the same NullReferenceException issue with the ReportParameter. Debugging the code with Q2 2012, we can find the ReportParameter[key].Value. Upgraded to Q2 2013 SP1, ReportParameter[key].Value is null. If we have control databinding with Parameters.key.Value in report, the value will be shown. However, we need the ReportParameter[key].Value in NeedDataSource event to process the data before actual binding. Is there any way we can work around?

Thanks
0
Stef
Telerik team
answered on 09 Sep 2013, 04:10 PM
Hi,

The running report parameters values can be obtainedin report's event from the processing equivalent of the report as illustrated in the Using Report Events help article, otherwise you will be working with the default set values.

For more details take a look at the Understanding Events help article.

I hope this helps.

Regards,
Stef
Telerik

Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

Tags
General Discussions
Asked by
Robert Michels
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Iron
Veteran
Iron
Robert Michels
Top achievements
Rank 1
Xiufeng
Top achievements
Rank 1
Stef
Telerik team
Share this question
or