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

Set value of subreport field

4 Answers 210 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 20 Jan 2010, 09:22 PM
In the calling application I am able to set the datasource of my subreport with:

 

Dim subRepItem2 As Telerik.Reporting.SubReport = TryCast(TryCast(ReportViewer1.Report, rptRemit).Items.Find("rptSubRemitTransactions", True)(0), Telerik.Reporting.SubReport)

 

subRepItem2.ReportSource.DataSource = ReportsDAL.RemitByTransDateHistory(

Me.txtStartingDate.SelectedDate)

I then try to customize the contents of a textbox based on the same report parameter but I get an error:

 

 

Dim txtbox As Telerik.Reporting.TextBox = TryCast(subRepItem2.Items.Find("txtTotalSince", True)(0), Telerik.Reporting.TextBox)

 

txtbox.Value =

"Total Since " & Me.txtStartingDate.SelectedDate.ToString

The error is:
System.IndexOutOfRangeException: Index was outside the bounds of the array.

Help please!

 

4 Answers, 1 is accepted

Sort by
0
Accepted
Steve
Telerik team
answered on 21 Jan 2010, 03:39 PM
Hi Tim,

If you debug your code you would immediately notice that you're trying to find a textbox item in the subreport item, which can have only a single child and that is a report.
The textbox is located in your detail report so the correct cast would be:

Dim txtbox As Telerik.Reporting.TextBox = TryCast(subRepItem2.ReportSource.Items.Items.Find("txtTotalSince", True)(0), Telerik.Reporting.TextBox)

All the best,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jacosa
Top achievements
Rank 1
answered on 28 Jun 2011, 09:16 AM

I also have a similar question; I want to set to visibility of the textbox in a subreport based on the value returned from my database in the code behind. My Main report is called: SectionA_Report

The SubReport is defined as:
Dim SubReport_SectionC As Telerik.Reporting.SubReport = TryCast(SectionA_Report.Items.Find("SubReport_SectionC", True)(0), Telerik.Reporting.SubReport)
'DataSource
SubReport_SectionC.ReportSource.DataSource = ApplicationForms_SectionC

To hide a value in my MainReport:
This works:  SectionA_Report.TextBox1.Visible = False

But in my SubReport I want to hide TextBox7?

0
Steve
Telerik team
answered on 28 Jun 2011, 09:40 AM
Hello Jacosa,

Using the code from the previous post, it should be:

Dim txtbox As Telerik.Reporting.TextBox = TryCast(subRepItem2.ReportSource.Items.Items.Find("txtTotalSince", True)(0), Telerik.Reporting.TextBox)
txtbox.Visible = False

Generally when you need to hide an item based on some condition/value, we highly recommend using Conditional Formatting.

Best wishes,
Steve
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Jacosa
Top achievements
Rank 1
answered on 28 Jun 2011, 10:15 AM

Thanks for the quick response,

 

Before my first post I used the information you posted to resolve the other users problem but I received the following highlighted error:

System.Collections.ObejectModel.Collection(Of T).Protected ReadOnly Property Items() AS System.Collections.Generic.IList(Of T) is not accessible in the context because it is 'Protected'

 

I check and the subReport and TextBox7 modifiers are set to: Friend, am I missing another setting somewhere.

 

Had a quick look at the Conditional Formatting and will it work similar to formulas in Crystal Reports?

Tags
General Discussions
Asked by
Tim
Top achievements
Rank 1
Answers by
Steve
Telerik team
Jacosa
Top achievements
Rank 1
Share this question
or