ReportViewer and UpdatePanel bugs RRS feed

  • Question

  • User390449127 posted

    I have page with two sections (tables).  On the left is a list of options for a report and a "Generate Report" button.  On the right is a ReportViewer control that displays the report's output.  This works well, but I wanted to put this into an UpdatePanel for a navigation reason.  If the user generates several reports and clicks the "Back" button on the browser, they are just redirected to the previous page.  If I put these controls within an UpdatePanel, when they click the "Back" button, they will go back through the previous page (not the previous report).

    When I put the left section (with the report options) in an UpdatePanel, there were no errors.  However, when I clicked the "Generate Report" button, nothing happened to the ReportViewer.  As I understand it, this is because the RV is outside of the UpdatePanel (?).  I have some code below that shows what I am doing in the button's event.

    I then moved the RV into the UpdatePanel, and got this JS error:

    parent.document.getElementByID(...) ClientController' is null or not a object. 

    In researching this, people just gave solutions like "move your ReportViewer out of the UpdatePanel".  Well, I could do that, but it would invalidate what I am trying to accomplish.  Is there a way to handle this?  I had two ideas:

    (1) Leave the RV outside of the UpdatePanel, and somehow cause it to refresh properly when the click event of my button is fired.

    (2) Resolve the error being caused when the RV is in an Update Panel.

    I would greatly appreciate any suggestions on how to resolve this issue.  Thank you!


        Private Function RenderReport(ByVal DataSetName As String, ByVal ReportDataView As DataView, _
                                      ByVal ReportPath As String, ByVal PanelIndex As Integer)
            'Render the report using the passed DataView.
                ReportViewer1.Visible = True
                ReportViewer1.Reset() 'This method will clear out previous report DataSets and allows one control to view multiple reports.
                'Set the report path of the report viewer
                ReportViewer1.LocalReport.ReportPath = ReportPath
                'Set the data source of the report to
                'the dataview returned by a Stored Procedure.
                ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource(DataSetName, ReportDataView.Table))
                ReportViewer1.CurrentPage = 1
            Catch ex As Exception
                lblError.Text = "Error in [RenderReport]: " & ex.Message
            End Try
        End Function
    Tuesday, January 27, 2009 10:29 AM

All replies

  • User-1193158323 posted


     Hi KarlR,

     Not sure if you still need a solution but here is what I did.  Since my scriptmanager and updatepanel are in the master page I needed a work around for the reportviewer. Basically what I did is turn of partial page rendering if the report is to be run.

    What I do is check which control caused the postback.  If its a button that generates the report then in the Page Init I turn off partial page rendering on the scripmanager (ctrl.EnablePartialRendering=False ).  This allows the update panel / partial page rendering to work while users select criteria and only perform a full post back when the "button_runquery" is clicked.

     Here is the code from my Page_Init.  Note that I use a custombase page that returns the _TargetEvent via its TargetEvent method.  You will need to implement this if you haven't already.

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

    If (IsPostBack ) then

    Dim Base As BasePage

    Base = Me.Page

    Dim ctrlname as String = String.Empty

    ctrlname = Base.EventTarget

    If (ctrlname.IndexOf("button_runquery") > 0) then

    _Master = Me.Master

    Dim ctrl As ScriptManager

    ctrl = _Master.FindControl("ScriptManager_Master")


    end if

    end if

    End Sub

    Hope this helps. Good Luck!

    Monday, March 2, 2009 12:52 PM
  • User390449127 posted

    Hi ProgKP,

    Yes, I am still looking for a solution to this issue.  I understand what you are trying to do (in concept), but I am having some problems implementing it on my page.

    For one, I don't use Master/Content pages on this site - it is just a "regular" page.  The "BasePage" type you are setting is not working for me (it doesn't know that type).  I have looked for an alternative to use, but I have been unsucessful.  What should I use for a non-Content page?

    Also, could you clarify what you meant about the "TargetEvent" method?  I have never used that before, and I would appreciate some guidance (or code).

    Thanks a lot for your reply!

    Monday, March 2, 2009 4:43 PM
  • User-1193158323 posted

    After reading all the properties on the reportviewer I found a much easier way.  Just set the AsyncRendering to false. With this approach you can leave PartialPage rendering on (clarification: no need to do anything to your page) and the reportviewer will work with your updatepanel.  Also I'm using Asp.net 3.5 not sure if this will work with prior versions.

    Example: ReportViewer.AsyncRendering =False

     Where ReportViewer is a reference to the Reportviewer control on your webpage.  Let me know if this doesn't work for you.

     Just ignore my prevous post, after testing it I found several conditions where it didn't work.  But to answer your question about EventTarget:

    EventTarget, is a function I added to my custom basepage, it is not part of the .net framework.  Basically it gets the control that forced the post back using  (Page.Request.Params("__EVENTTARGET"))

     I'm still testing this in my code but so far it has worked every time.

    Thursday, March 5, 2009 2:47 PM
  • User390449127 posted

    Well, I think you are getting closer.  [8-|]

    However, I am still having a "minor" issue.  If I change the AsyncRendering property to False (from the properties panel on the page itself), almost everything works.  My initial page load is correct, and when I click my button to refresh the ReportViewer based on selections, it refreshes with the changes.  What does not work are the "Export" and "Print" functions of the ReportViewer.  On the initial page load a report is shown.  If I click the [export type] drop-down and select either Excel or PDF, I can then click the "Export" button and it is generated correctly.  However, after I click the button to refresh the ReportViewer, this "Export" button does nothing.  Same functionality for the "Print" icon.

    Should I be setting this property on the page itself or within the code somewhere?  I have experimented with setting this in the Page_Load, _Init, and _InitComplete events, but that just causes the original problem (the ReportViewer does not refresh when the button is clicked on the page).  I would appreciate any more help you could give me & I appologize if I am misunderstanding you post.

    Thanks again for your help!

    Friday, March 6, 2009 3:13 PM
  • User-1193158323 posted

    Appologies for not getting back to you sooner (i don't check email everyday).

    I did check my code and have the same problem as you with the export and print buttons.  So I think you did it correct.  I should warn you this is my first time using this control.  Unfortunetly, I've had to put this proeject on the back burner for now.  I'll try to get back to this on the weekend and let you know what I found.

    Tuesday, March 10, 2009 11:49 AM
  • User390449127 posted

    No reason to appologize - I appreciate any suggestions you can give me.  I am glad you have the same issue with the export & print buttons as I do.

    Please post back if you make any progress & thanks again!

    Tuesday, March 10, 2009 1:13 PM
  • User66805156 posted

    Realize it's been a while since this post . . . I've had success keeping my report viewer in an update panel by adding the reportViewer as a postback trigger:


    <asp:PostBackTrigger ControlID="ReportViewer1" />


    This will allow the rest of the page to be ajaxified while allowing the report itself to be in AsyncRendering.   Export & Print buttons work for me as well. 

    Thursday, August 18, 2011 3:46 PM
  • Thursday, August 18, 2011 11:09 PM