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

Report viewer error with textbox

2 Answers 87 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 12 Mar 2012, 08:17 PM
I have a single report viewer that I use to show multiple reports. In each of the reports I have a text box called FooterTextBox which places text with the footer of the report at run time. I get errors in the Error List: 'FooterTextBox' is not  a member of 'Telerik.Reporting.Report' of the VS 2010 IDE.

If I ignore the errors during build time the program runs fine and can change the footer text with no issues. However when I am building additional reports the build fails (in the preview) unless I comment out these lines ?        

If Me.FooterTextbox.Text <> "" Then

            myReport.FooterTextBox.Value = Me.FooterTextbox.Text
        Else
            myReport.FooterTextBox.Value = "Printed copies are uncontrolled documents."
        End If 


Report code:

        Dim myReport As Telerik.Reporting.Report = Nothing
        Select Case ReportDDL.SelectedItem.Value
            Case "OSHAItembyPersonnelReport"
                myReport = New OSHAItembyEmployeeReport
                Exit Select
            Case "OSHAItems"
                myReport = New OSHAItems
                Exit Select
            Case "OSHAItemDue"
                myReport = New OSHAItemDue
                Exit Select
        End Select
        Me.ReportViewer1.Report = myReport

        If Me.FooterTextbox.Text <> "" Then
            myReport.FooterTextBox.Value = Me.FooterTextbox.Text
        Else
            myReport.FooterTextBox.Value = "Printed copies are uncontrolled documents."
        End If

        Me.ReportViewer1.RefreshReport()
        Me.ReportViewer1.Report = myReport

2 Answers, 1 is accepted

Sort by
0
Accepted
Elian
Telerik team
answered on 13 Mar 2012, 01:39 PM
Hi Andy,

The FooterTextBox should be a private variable and nothing outside of the report shouldn't be aware of it. 
One way to do this is to pass a parameter to the reports which will determine the value of this textbox. The other way is to access the TextBox in a slightly different way:

Dim txtBox = TryCast(myReport.Items("reportFooterSection1").Items("FooterTextBox"), Telerik.Reporting.TextBox)
By using the Items collection you can access all elements of the report hierarchically (if the textBox is in the page footer, then you need to access the page footer first). Kind regards,
Elian
the Telerik team
NEW in Q1'12: Telerik Report Designer (Beta) for ad-hoc report creation. Download as part of Telerik Reporting Q1 2012. For questions and feedback, use the new Telerik Report Designer Forum.
0
Andy
Top achievements
Rank 1
answered on 13 Mar 2012, 02:33 PM
Thanks worked like a charm. I'm still new to Vb.net so I am learning as I go.
Tags
General Discussions
Asked by
Andy
Top achievements
Rank 1
Answers by
Elian
Telerik team
Andy
Top achievements
Rank 1
Share this question
or