Problem with detail_ItemDataBound event, passing a parameter to subreport

4 posts, 0 answers
  1. Lucio
    Lucio avatar
    6 posts
    Member since:
    Jan 2018

    Posted 02 Apr 2018 Link to this post

    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)
  2. Lucio
    Lucio avatar
    6 posts
    Member since:
    Jan 2018

    Posted 02 Apr 2018 in reply to Lucio Link to this post

    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();
                //.....
            }

  3. Katia
    Admin
    Katia avatar
    693 posts

    Posted 05 Apr 2018 Link to this post

    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
  4. Lucio
    Lucio avatar
    6 posts
    Member since:
    Jan 2018

    Posted 26 Apr 2018 in reply to Katia Link to this post

    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;
            }

Back to Top