Friday, March 30, 2012

ReportViewer does not refresh when rdlc file changes

Hi,

I am trying to change rdlc file at run time but it does not resfresh.

I know there is an option to use Reset method but my version of ReportViewer

does not have this method. Does someone know how to change rdlc files

dynamically without using Reset ?

Thanks

Hi,

From your description, it seems that you want to change the report at runtime, right?

I think what you can do is to write a method in your code behind file which assigns the reportpath,datasources property and calls the refreshReport method, and invoke that method in the any event you want. See the following code snippet:

ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = "rdlc file path";
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("ReportDataSet_XX", ReportDataSet.Tables[int i]));
ReportViewer1.DocumentMapCollapsed = true;
ReportViewer1.RefreshReport();

For more information, you can refer the following threads:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2421083&SiteID=1

Thanks.

|||

Thanks for the reply.

This is exactly what I have in the code except this line.

ReportViewer1.DocumentMapCollapsed = true;

I have added this line and the result as following:

When I set first time reportviewer to rdlc, it works as expected.

When in another event, I am resetting.ReportPath and.DataSources to something different,

I get "

  • Some parameters or credentials have not been specified".|||

    Hi,

    The error "some parameters or credentials have not been specified" indicates that you have not set your parameters well, which is needed for your report.

    And based on the code you provided,

    List<ReportParameter> paramList =newList<ReportParameter>();this.ReportViewer1.LocalReport.SetParameters(paramList);

    You have created a ReportParameterList, but you haven't add any report parameter to the parameter list.

    Thanks.

    |||

    Thanks,

    That is the part of the problem, first rdlc has 2 parameteres

    but second one has no parameters and when I reset to second one it goves me this message.

    |||

    List<ReportParameter> paramList =newList<ReportParameter>();this.ReportViewer1.LocalReport.SetParameters(paramList);

    As the second report has no parameters, remove the above line, you are adding an empty parameter list.

  • No comments:

    Post a Comment