locked
Passing parameter to ReportViewer RRS feed

  • Question

  • User366630179 posted

    Hi All,

    I have a session variable that I would like to pass as a parameter to a report.  Currently I have the following code:

    <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" Height="589px" ProcessingMode="Remote" Width="1050px">
    <ServerReport ReportPath="/OnTrack/TerminationReport" ReportServerUrl="http://1.1.1.1/reportserver" />

    </rsweb:ReportViewer>

    Any way to do this?

    Many thanks,

    Mark

    Friday, December 9, 2011 9:16 AM

Answers

  • User-59488345 posted

    Here is a sub I had previously used but then commented out:

    'Public Sub AddParameters()
        '    'Set the Processing  mode for the ReportViewer to Remote
        '    'ReportViewer1.ProcessingMode = ProcessingMode.Remote
    
        '    Dim ServerReport As ServerReport
        '    ServerReport = ReportViewer1.ServerReport
    
        '    'Get a reference to the default Credentials
        '    Dim Credentials As System.Net.ICredentials
        '    Credentials = System.Net.CredentialCache.DefaultCredentials
    
        '    'Get a reference to the report server credentials
        '    '' Dim rsCredentials As ReportServerCredentials
        '    ' rsCredentials = ServerReport.ReportServerCredentials
    
        '    'Set the report server URL and Report Path
        '    'ServerReport.ReportServerUrl = _
        '    '  New Uri("http://myServer/ihreportserver")
        '    'ServerReport.ReportPath = _
        '    '  "/Reports/HotelsForecastAnalysisTabular"
    
        '    'Create the report parameters for the report
        '    Dim p1 As String = "xxxxx"
        '    Dim p2 As String = "yyyyy"
        '    Dim Param1 As New ReportParameter()
        '    ParamSite.Name = "p1Name"
        '    ParamSite.Values.Add(p1)
    
        '    Dim Param2 As New ReportParameter()
        '    ParamBlock.Name = "p2Name"
        '    ParamBlock.Values.Add(p2)
    
        '    'Set the report Parameters for the report
        '    Dim Parameters() As ReportParameter = {Param1, Param2}
        '    ServerReport.SetParameters(Parameters)
        '    'Refresh the report
        '    'ReportViewer1.RefreshReport()
        'End Sub
    
    
    It's based on sample here:
    http://social.msdn.microsoft.com/Forums/en/vsreportcontrols/thread/ca78318d-61d6-4941-91e2-8ec2ae519722
    
    
    It worked OK - just call it on Page Load
    
    
    Edit:
    obvously replace
    Dim p1 As String = "xxxxx" with your Session value
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 9, 2011 11:22 AM

All replies

  • User-59488345 posted

    Here is a sub I had previously used but then commented out:

    'Public Sub AddParameters()
        '    'Set the Processing  mode for the ReportViewer to Remote
        '    'ReportViewer1.ProcessingMode = ProcessingMode.Remote
    
        '    Dim ServerReport As ServerReport
        '    ServerReport = ReportViewer1.ServerReport
    
        '    'Get a reference to the default Credentials
        '    Dim Credentials As System.Net.ICredentials
        '    Credentials = System.Net.CredentialCache.DefaultCredentials
    
        '    'Get a reference to the report server credentials
        '    '' Dim rsCredentials As ReportServerCredentials
        '    ' rsCredentials = ServerReport.ReportServerCredentials
    
        '    'Set the report server URL and Report Path
        '    'ServerReport.ReportServerUrl = _
        '    '  New Uri("http://myServer/ihreportserver")
        '    'ServerReport.ReportPath = _
        '    '  "/Reports/HotelsForecastAnalysisTabular"
    
        '    'Create the report parameters for the report
        '    Dim p1 As String = "xxxxx"
        '    Dim p2 As String = "yyyyy"
        '    Dim Param1 As New ReportParameter()
        '    ParamSite.Name = "p1Name"
        '    ParamSite.Values.Add(p1)
    
        '    Dim Param2 As New ReportParameter()
        '    ParamBlock.Name = "p2Name"
        '    ParamBlock.Values.Add(p2)
    
        '    'Set the report Parameters for the report
        '    Dim Parameters() As ReportParameter = {Param1, Param2}
        '    ServerReport.SetParameters(Parameters)
        '    'Refresh the report
        '    'ReportViewer1.RefreshReport()
        'End Sub
    
    
    It's based on sample here:
    http://social.msdn.microsoft.com/Forums/en/vsreportcontrols/thread/ca78318d-61d6-4941-91e2-8ec2ae519722
    
    
    It worked OK - just call it on Page Load
    
    
    Edit:
    obvously replace
    Dim p1 As String = "xxxxx" with your Session value
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 9, 2011 11:22 AM
  • User366630179 posted

    Cheers!

    Friday, December 9, 2011 2:28 PM