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

TextBox ItemDataBound problem

5 Answers 438 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Roman
Top achievements
Rank 1
Roman asked on 20 Apr 2011, 03:08 PM
Hello!

I'm learning Telerik Reporting and today i found an example how to get a value from textbox in subreport and set this value to master report textbox. 

When i did this example in silverlight project with wcf ria services i get an error in ItemDataBound event.

My code for textBox1 ItemDataBound event is this
private void textBox3_ItemDataBound(object sender, EventArgs e)
        {
            Telerik.Reporting.Processing.TextBox textBox1_1 = (Telerik.Reporting.Processing.TextBox)sender;
            Telerik.Reporting.Processing.Report oReport = textBox1_1.Report;
            Telerik.Reporting.Processing.DetailSection oDetailSection = (Telerik.Reporting.Processing.DetailSection)oReport.ChildElements.Find("detail", true)[0];
            Telerik.Reporting.Processing.SubReport oSubReport = (Telerik.Reporting.Processing.SubReport)oDetailSection.ChildElements.Find("subReport1", true)[0];
            //Telerik.Reporting.Processing.DetailSection oSubReportDetailSection = (Telerik.Reporting.Processing.DetailSection)oSubReport.ChildElements.Find("detail", true)[0];
            Telerik.Reporting.Processing.TextBox oSubReportTextBox = (Telerik.Reporting.Processing.TextBox)oSubReport.InnerReport.ChildElements.Find("textBox1", true)[0];
            textBox1_1.Value = oSubReportTextBox.Value;
        }
But i get error in this line Telerik.Reporting.Processing.TextBox oSubReportTextBox = (Telerik.Reporting.Processing.TextBox)oSubReport.InnerReport.ChildElements.Find("textBox1"true)[0];
It says that ther is no InnerReport (null) but i set a subreport1.ReportSource to my subreport in design viewer.

I subreport i have only detail section with two textboxes (one with simple text and one with =5*5 calculation). 

What am i doing wrong? 

5 Answers, 1 is accepted

Sort by
0
Massimiliano Bassili
Top achievements
Rank 1
answered on 22 Apr 2011, 02:59 PM
What is the sequence of items i.e. is textBox1 created before the subreport item? It will be if it is first in the detail items collection, so change the order. Generally if you've come to a situation where you need to get value from detail report inside the master, it means that your design is wrong. The master should not need a value from the detail, it should be the other way around.

Cheers!
0
Mark
Top achievements
Rank 1
answered on 01 May 2014, 09:58 PM
Hi,
Sorry to butt in but you mentioned "The master should not need a value from the subreport." However, I have two subreports each with a calculated total field that I need to display in the summary info of the master report.
Can you explain the best way this can be done please?
Thank you,
Mark Wyatt
0
Stef
Telerik team
answered on 06 May 2014, 12:34 PM
Hello Mark,

Please check the attached sample project. The data is organized in a data model, in such manner we can use the approach for data binding illustrated in the How to use the ReportItem.DataObject property in expressions help article. The sub report's DataSource is set via Binding, as well as the other data items DataSource properties.

The benefit of this approach is that you have the data on the level of the master report, and can make the calculations based on the data and use them in expressions.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Mark
Top achievements
Rank 1
answered on 06 May 2014, 02:46 PM
Hi Stef,

First let me thank you for your assistance. I'm still trying to wrap my head around this. I've used Activereports for 15 years so bear with me. I'm trying to get up to speed on how Telerik Reports are put together.

Why isn't the expression, "='sub report totals:' + Fields.SubData.Total" not working from your example? (Please see attached)

Sincerely,
Mark
0
Stef
Telerik team
answered on 06 May 2014, 03:40 PM
Hello Mark,

The expression returns the value of the used business object's property. The property in code set as follows:
public string Total { get { return String.Join("|", FortheSubTable); } }
It is actually a custom logic to calculate and return the needed information in the report. Thus we avoid the dependency from the report layout and rely entirely on the data structure to visualize data, where it is required.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Roman
Top achievements
Rank 1
Answers by
Massimiliano Bassili
Top achievements
Rank 1
Mark
Top achievements
Rank 1
Stef
Telerik team
Share this question
or