Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello everyone,
I've created a report using Sql Server Report Builder 3.0 with SQL Server 2008R2.I've saved the report in local machine. The report populates data fine. Now my requirement is that I'll have to view that report on a button click inside a reportviewer in a .aspx page.

I've put the report in the same solution folder and tried the following codes:--
1>
C#
Microsoft.Reporting.WebForms.LocalReport report = new Microsoft.Reporting.WebForms.LocalReport();
  report.ReportEmbeddedResource = "ReportViewer.Report.rdl";
  report.Refresh();

This doesn't show any error but the report isn't showing either.

2>
C#
ReportViewer1.LocalReport.ReportEmbeddedResource = "Report.rdl";
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
ReportViewer1.Visible = true;

This code gives the error :-- An error occurred during local report processing.
The report definition for report 'Report.rdl' has not been specified.
3>
C#
StreamReader strm = new StreamReader(@"~\Report.rdl");
         ReportViewer1.LocalReport.LoadReportDefinition(strm);
         ReportViewer1.LocalReport.Refresh();

This one also doesn't show the report.

Please give me solution.
Posted
Updated 7-May-13 5:54am
v2

1 solution

Hi,

Please review the following:
I have developed a report using New Report in Visual Studio 2008 (rdlc format) and Visual Studio Data Sources.

C#
this.reportViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;

this.reportViewer.LocalReport.ReportPath = Server.MapPath("Your report path.rdlc");

//If you want to generate dynamic data then 
//query the database using C# and fill a DataTable (named data in this case)
//and then assign it to the reportviewer data source as following:
this.reportViewer.LocalReport.DataSources.Clear();
this.reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSourceName", data));

//If your front end has custom parameter input then do the following
Microsoft.Reporting.WebForms.ReportParameter[] parameters = new Microsoft.Reporting.WebForms.ReportParameter[3];

parameters[0] = new Microsoft.Reporting.WebForms.ReportParameter("ParameterName1", staffMemberDisplay, true);
parameters[1] = new Microsoft.Reporting.WebForms.ReportParameter("ParameterName2", startDate, true);
parameters[2] = new Microsoft.Reporting.WebForms.ReportParameter("ParameterName3", endDate, true);
this.reportViewer.LocalReport.SetParameters(parameters);

//Refresh the report
this.reportViewer.LocalReport.Refresh();


I hope this helps.
Feel free to ask questions if any.

Happy coding..!!

Regards,
Nayan
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900