none
ASP.NET parameter to SSRS - Continuous refresh issue RRS feed

  • Question

  • Hi

    I am trying to pass a session value from my web application into an SSRS report via the report viewer control. Code as follows...

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            rptAdviceNote.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote
            rptAdviceNote.ServerReport.ReportServerUrl = New Uri("http://arm-svr/ReportServer_ARM")
            rptAdviceNote.ServerReport.ReportPath = "/Intranet Reports/Advice Note (Latest)"
            rptAdviceNote.SizeToReportContent = True
            Dim rptParam(0) As Microsoft.Reporting.WebForms.ReportParameter
            rptParam(0) = New Microsoft.Reporting.WebForms.ReportParameter("Order_id", CType(Session("AnalysisOrder"), Integer))
            rptAdviceNote.ServerReport.SetParameters(rptParam)
        End Sub

    The SSRS report calls a stored procedure, the report parameter is set as follows...

    DataType=Integer

    AllowNullValues=Yes

    SelectParameterVisibility=Internal

    AvailableValues=None

    DefaultValues=SpecifyValues=0

    Advanced=AutomaticallyDetermineWhenToRefresh

    When i run the report, i can see the parameter value displayed in the toolbar  but the report viewer seems to get stuck in an infinite loop of repeated refresh attempts. When i run the report from the report manager and supply the parameter manually, the report displays fine. I am using...

    VS2010

    SQL Server 2008

    If anyone could help me with this, i would be very grateful.

    Many thanks.

    Steve Flynn

    Monday, August 2, 2010 9:13 AM

Answers

  • The culprit is the ServerReport.SeParameters() method in Page_Load. It will always cause the reportviewer to execute the report on the NEXT async postback. You can do one of two things:

    1. Change Page_Load to Page_Init, as everything in your code looks to be constant settings in your app.

    2. Move your code to within an if(!IsPostBack) {} block. This makes sure that the parameters are set only when the page is first loaded. For example:

    if(!IsPostBack)
    {
       rptAdviceNote.ServerReport.SetParameters(rptParam)
    }


    Cephas Lin This posting is provided "AS IS" with no warranties.
    • Marked as answer by Steve_Flynn Tuesday, August 3, 2010 8:03 AM
    Monday, August 2, 2010 3:23 PM
    Moderator

All replies

  • The culprit is the ServerReport.SeParameters() method in Page_Load. It will always cause the reportviewer to execute the report on the NEXT async postback. You can do one of two things:

    1. Change Page_Load to Page_Init, as everything in your code looks to be constant settings in your app.

    2. Move your code to within an if(!IsPostBack) {} block. This makes sure that the parameters are set only when the page is first loaded. For example:

    if(!IsPostBack)
    {
       rptAdviceNote.ServerReport.SetParameters(rptParam)
    }


    Cephas Lin This posting is provided "AS IS" with no warranties.
    • Marked as answer by Steve_Flynn Tuesday, August 3, 2010 8:03 AM
    Monday, August 2, 2010 3:23 PM
    Moderator
  • Perfect, thanks. I'm coding in VB so I used 'IF NOT page.ispostback THEN' but it worked just the same. Thanks again.

    Steve

    Tuesday, August 3, 2010 8:03 AM