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

Silverlight Report with multi SubReports

1 Answer 59 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Roman
Top achievements
Rank 1
Roman asked on 24 Mar 2011, 02:59 PM
Hy,

i'm working with Telerik Reporting and have some problems. I create one master report where i have report parameters and a header of the page. After user selects values for parameters (2x datetime, 4x Integer, 1x Boolean) i want to show right SubReport (if true then subreport1 else subreport2). Those two subreports use 6 parameter values from master report parameteres and I pass those values to SqlDataSource in each subreport.

If I delete one SubReport field my report works as it should. But if I have two SubReport fields on master report i get "Object reference not set to an instance of an object." I dont have any idea what i'm doing wrong.

I have test each subreport in designer and datasource are ok. In master report i have two DataBound methods where I set Visible to true or false which subreport to show.

public static bool subMeseci = true;
 
private void subReport_PoMesecih_ItemDataBound(object sender, EventArgs e)
        {
             
            subMeseci = (bool)this.ReportParameters["months"].Value;
            if (subMeseci)
                (sender as Telerik.Reporting.Processing.SubReport).Visible = true;
            else
                (sender as Telerik.Reporting.Processing.SubReport).Visible = false;
             
        }
 
        private void subReport_Vse_ItemDataBound(object sender, EventArgs e)
        {
             
                subMeseci = (bool)this.ReportParameters["months"].Value;
                if (subMeseci)
                    (sender as Telerik.Reporting.Processing.SubReport).Visible = false;
                else
                    (sender as Telerik.Reporting.Processing.SubReport).Visible = true;
        }

I also set all 6 parameters that i use in subreport datasource.

I have attached two photos (one is my master report wher i have two subreports in detail section, and other shows report parameters that i pass to subreport).

First I was thinking that i do something wrong when i'm passing parameters to subreport but as i mentioned in the begining if i delete one subreport field from master report it works ok.

Sorry for my english but i hope you get the point what my problem is.

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 29 Mar 2011, 05:53 PM
Hello Roman,

We are not sure what is causing the described behavior. However we have noticed that you are using the Definition item of the Report Parameters instead of the Processing one. This way you actually get the Report Parameter's default value. Generally for your scenario our suggestion is to Binding the Subreport.Visible property with the expression = Parameters.months.Value

Let us know how it goes and if you experience any difficulties we will appreciate if open a support ticket and send us a sample project.

You may find useful the following help articles:

Kind regards,
Peter
the Telerik team
Tags
General Discussions
Asked by
Roman
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or