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

Problem with detail_ItemDataBound event, passing a parameter to subreport

3 Answers 108 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Lucio
Top achievements
Rank 1
Lucio asked on 02 Apr 2018, 06:53 PM
I have a main report that lists cities, and I have a subreport for each city that lists buildings of them. I mean, subreport presents the detail of buildings of each city od the main report.

I want to pass a parameter to each sub report, this parameter is a value of a textbox in the main report. I'm passing this parameter in the "detail_ItemDataBound" event (main report), and then I intend to read it in the subreport, in the "NeedDataSource" event. The problem is that the parameter that corresponds to the first row appers in the second row, and the parameter that is part of the second row appers in the third one.

What am I doing wrong? or Does it have any mistake those telerik events?

I apreciate your help.

(I'm using Telerik Reporting R1 2018)

3 Answers, 1 is accepted

Sort by
0
Lucio
Top achievements
Rank 1
answered on 02 Apr 2018, 07:08 PM

Code from main report:

        private void detail_ItemDataBound(object sender, EventArgs e)
        {
            Telerik.Reporting.Processing.DetailSection detalle = (Telerik.Reporting.Processing.DetailSection)sender;
            Telerik.Reporting.Processing.TextBox txtIDEstadoCodeBehind = (Telerik.Reporting.Processing.TextBox)detalle.ChildElements["txtIDEstado"];
            detalle.Parent.Report.Parameters["MiParametro"].Value = txtIDEstadoCodeBehind.Text;
            txtCiudad.Value += "";
        }

 

Code from subreport:

        private void Anexo5SubRepInmBrigadista_NeedDataSource(object sender, EventArgs e)
        {
            Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;
            textBox33.Value = report.Parent.Report.Parameters["MiParametro"].Value.ToString();
            //.....
        }

0
Katia
Telerik team
answered on 05 Apr 2018, 12:33 PM
Hi Lucio,

Applying changes to the item definition in events is not supported. For example, changes applied to the TextBox definitions will not be applied:
txtCiudad.Value += "";
textBox33.Value = report.Parent.Report.Parameters["MiParametro"].Value.ToString();

In events it is allowed to modify only the processing item. Examples of modifying processing items are provided in the following articles:
Changes on items in report events are not applied
Understanding Events

I recommend passing the values to subreport parameters at design-time - when configuring the ReportSource property of the SubReport item in report designer. More details are available in Passing Parameters to a SubReport.

I hope this information will help to resolve the issue.


Regards,
Katia
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Lucio
Top achievements
Rank 1
answered on 26 Apr 2018, 04:01 PM

Hi Katia

Thanks for your comments.
I solved it by passing parameters in the textbox's event "ItemDataBound".

And... Tha'ts all!  It works!

        private void txtIDCiudad_ItemDataBound(object sender, EventArgs e)
        {
            Telerik.Reporting.Processing.TextBox txtIDCiudadCodeBehind = (Telerik.Reporting.Processing.TextBox)sender;
            txtIDCiudadCodeBehind.Parent.Report.Parameters["idCiudad"].Value = txtIDCiudadCodeBehind.Text;
        }

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