ReportViewer - PDF/Printing issue with Custom Code variables RRS feed

  • Question

  • I am using the Visual Studio 2005 ReportViewer control and I have created a textbox to store the customer name in the Page Header.  This textbox uses a custom function to reference field data in the details section of a table.  Here is a sample of my code that I am calling from my customer textbox:


        Shared _customerName As String
        Public Function GetCustomerName(ByVal customerName As String) As String
            If Not customerName Is Nothing Then
                _customerName = customerName
            End If
            Return _customerName
        End Function


    I created the custom function because I am grouping by customer name and you can't reference field data in the page header.  In my example, I have a 4 page report with 1 page for each customer.  When the report runs, it will display the unique customer name on each page.  When I run the report, everything works fine.  The problem is, when I print the report or export it as a .pdf, the customer name contains the same name on all 4 pages.  I assume this is because I am using a shared variable in my custom code.  But, it works fine when I preview the report or export it to Excel, so I don't understand why it wouldn't work for printing or exporting to .pdf.


    Does anyone have a solution for this?

    Thursday, May 8, 2008 7:34 PM

All replies