none
Refresh Button in Report Viewer not working properly RRS feed

  • Question

  • Hi

    I am creating Windows Application.

    I have created the Report using the Report Viewer.

    The report is generated but the reportviewers refresh button is not working.

    I have also included the following code for refresh:

    private void reportViewer1_ReportRefresh(object sender, CancelEventArgs e)
            {
                reportViewer1.Refresh();
            }


    Can any body tell me what should I do to Refresh the report in the report viewer?

    Thanks in advance!
    Saturday, July 11, 2009 10:11 AM

Answers

  • The Refresh method you are calling is inherited from the base Control class and just redraws the current display in the winform.  I'm assuming that you want the data in the reort refreshed.  If you are using local mode, then you will need to supply new data to the ReportViewer.LocalReport object in the ReportRefresh event, since it is the host application that is responsible for executing queries in local mode.  In server mode, this should be happening automatically.
    • Marked as answer by SNK08 Sunday, July 12, 2009 3:54 AM
    Sunday, July 12, 2009 12:57 AM
    Moderator

All replies

  • The Refresh method you are calling is inherited from the base Control class and just redraws the current display in the winform.  I'm assuming that you want the data in the reort refreshed.  If you are using local mode, then you will need to supply new data to the ReportViewer.LocalReport object in the ReportRefresh event, since it is the host application that is responsible for executing queries in local mode.  In server mode, this should be happening automatically.
    • Marked as answer by SNK08 Sunday, July 12, 2009 3:54 AM
    Sunday, July 12, 2009 12:57 AM
    Moderator

  • The Refresh method you are calling is inherited from the base Control class and just redraws the current display in the winform.  I'm assuming that you want the data in the reort refreshed.  If you are using local mode, then you will need to supply new data to the ReportViewer.LocalReport object in the ReportRefresh event, since it is the host application that is responsible for executing queries in local mode.  In server mode, this should be happening automatically.

    Thanks for your reply.

    I am able to refresh the report now.

    Thanks a lot!
    Sunday, July 12, 2009 3:55 AM
  • @SNK 

    Hi, 

    I have the same problem can you show me your code how did you handle that???? I am not getting it :(((

    Thursday, June 24, 2010 6:38 PM
  • TechCrank,

    Likely you already have the code for loading data in Form_Load. It looks like:

     

     

    this.Table1TableAdapter.Fill(this.DataSet1.Table1);

    You need to add this line of code in the ReportRefresh event.


    Cephas Lin This posting is provided "AS IS" with no warranties.
    Thursday, June 24, 2010 10:52 PM
    Moderator
  • @Cephlin 

    I did it and when I debug my dataset in the after calling TableAdapter its giving me the same old data. 


    private void reportViewer1_ReportRefresh(object sender, CancelEventArgs e)
            {
                this.Inven1TableAdapter.Fill(this.InventO.Inven1,Int32.Parse(ddlGodown.SelectedValue.ToString()));

                this.reportViewer1.RefreshReport();
            }



    Friday, June 25, 2010 7:24 AM
  • Are you subscribing to the ReportRefresh event? The code above will not be reached unless you subscribe.

    Set a breakpoint in your code above and see if it's reached when you click the View Report button.


    Cephas Lin This posting is provided "AS IS" with no warranties.
    Monday, June 28, 2010 3:30 PM
    Moderator
  • Yeah subscribing to this even t also does not work. I subscribed to this event but when debugging it does not even come to this event. There is a lot of discussion going on this item on many places and nothing works.

                ReportViewer1.SizeToReportContent = true;
                ReportViewer1.LocalReport.ReportPath = Server.MapPath("/Reports/TestReportViewer.rdlc");
                ReportViewer1.LocalReport.DataSources.Clear();
                ReportDataSource rSource = new ReportDataSource("DataSet1", dt);
                ReportViewer1.LocalReport.DataSources.Add(rSource);
                ReportViewer1.ReportRefresh += new CancelEventHandler(OnReportRefresh);
                ReportViewer1.LocalReport.Refresh();

            private void OnReportRefresh(object sender, CancelEventArgs e)
            {
                DataTable dt = GetData();
                this.ReportViewer1.LocalReport.Refresh();
            }

    The debug does not even come into this OnReportRefresh() method.


    Ramachandran

    Monday, October 23, 2017 12:15 AM
  • Just wanted to make it clear that I am using the refresh button inside the reportviewer control and this is webforms

    Ramachandran

    Monday, October 23, 2017 12:16 AM