p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional SQL Server 2005 Reporting Services ISBN: 0-7645-8497-9 (http://p2p.wrox.com/forumdisplay.php?f=251)
-   -   "ReportItems" collection re header/footer (http://p2p.wrox.com/showthread.php?t=45189)

ucgtfh35 September 10th, 2006 08:52 PM

The data is processed seperately from the rendering of the report. ReportItems collection items have individual scopes and kludges in which fields are forced to repeat across pages can be used to set header/footer fields on those pages. Besides the ReportItems collection, Globals and Parameters can also be used to set header/footer field content. In a local report, parameter values may not be set to Field values. However, the ReportViewer webcontrol exposes the report's Parameters. Therefore, you can set the report parameters by using the ReportViewer's LocalReport SetParameters method. A couple of code behind examples:

    ' the first report parameter from a DropDownList
    Dim selectedItem As String = Me.DropDownList1.SelectedValue

    ' the second report parameter from an ObjectDataSource DataView DataRow Item
    ' (that is; a field)
    Dim irow As Integer = 0
    Dim icol As Integer = 0
    Dim activeView As System.Data.DataView = Me.ObjectDataSource2.Select()
    Dim cellItem As String = activeView.(irow)(icol).ToString()

    ' set the ReportViewer's parameters (same as the parameters defined in the report's .rdlc)
    Dim params(1) As Microsoft.Reporting.WebForms.ReportParameter
    param(0) = New Microsoft.Reporting.WebForms.ReportParameter("rpti d", selectedItem)
    param(1) = New Microsoft.Reporting.WebForms.ReportParameter("rptg rp", cellItem)
    ' create the new report

A report with header or footer fields contents set to the report parameter values will display these on each page.


ucgtfh35 September 10th, 2006 09:00 PM

oops, transcription error...

    params(0) = ...
    params(1) = ...

brewmanz July 21st, 2008 07:10 PM

I have multi-page lists-within-lists and it only shows the correct value on the first page heading of the report - in my case a Period End date that is the same for all records. I used the following trick to save the value (in this case a date field) for subsequent page headings:
In Report - Properties - Code
   Public Function StoreFirstValue_PeriodEndDateFromExtract(aDT as DateTime) as DateTime
        Static dtPeriodEndDateFromExtract as DateTime
        if dtPeriodEndDateFromExtract.Year < 999 then
            dtPeriodEndDateFromExtract = aDT
        end if
        return dtPeriodEndDateFromExtract
    End Function
the text box uses the following expression:
="Period Ending " & Code.StoreFirstValue_PeriodEndDateFromExtract(CDat e(First(ReportItems("textboxPeriodEndDateFromExtra ct").Value))).ToString("d MMMM yyyy")


All times are GMT -4. The time now is 11:03 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.