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

Processing data in subreports, code can't read report parameters

1 Answer 70 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Clifton
Top achievements
Rank 1
Clifton asked on 13 Aug 2019, 02:31 PM

I have a master report and a subreport.  The master report has a section that is assigned a data source and creates a line for each item in the data source, and one segment of that section is the subreport.  This is all done in UI, not programmatically.  The parameters are set up and sent properly, and if I just assign the parameters to a textbox in the subform, they are rendered properly.  However, I need that subreport to take a parameter and do some programmatic work, not just assign it to a field with UI configurations.  In this case, it reads a string parameter, calls other code with that string to generate more data, and uses that data to draw custom text objects on the form.

The parameter passing to a field works fine.  The code that reads does the extra building works fine.  What doesn't work is that the code in the subform is unable to read the parameters.  If I read ReportParamters[0].Value in the constructor method of the subform, it returns the default value of the parameter, not the value that shows up in the textbox.  I have tried capturing each of the raised events and testing on those points, all with the same results.  So far, it appears that the ReportParameters are not passed to the subform until all of the code-based events have transpired.  If I try to read the text-box programmatically, the value given is the formula for the parameter, not the value of the passed parameter.  Is there an event that I am missing, or is a subform just not expected to do any programmatic work with the parameters given?

1 Answer, 1 is accepted

Sort by
0
Clifton
Top achievements
Rank 1
answered on 13 Aug 2019, 07:15 PM

Solved with a specific congruence of events and timing.

1. In the subform constructor, create an event handler for the ItemDataBinding event.

2. In that event, cast the "sender" object to a Telerik.Reporting.Processing.Report object.

3. Read the processingReport.Parameters[] values, do the required work.   ReportParameters[] only ever shows the default values.

If you do this on the ItemDataBound event, objects that you add to the form programatically do not show up in the rendered result, so it must be done in the ItemDataBinding event.

Tags
General Discussions
Asked by
Clifton
Top achievements
Rank 1
Answers by
Clifton
Top achievements
Rank 1
Share this question
or