Showing posts with label RDL Reporting. Show all posts
Showing posts with label RDL Reporting. Show all posts

Wednesday, January 12, 2011

"A data source instance has not been supplied for the data source" exception w/ Report Viewer Control

This exception occurs in a number of scenarios, in my case, it pop up because i forgot to add this line before the refresh of the reportviewer in the form load event trigger:

 this.[data source name].DataSource = [data object];

where [data source name] is the data source object created and the [data object] is the business object that talks to the database to retrieve the relevant data for report display

Thursday, January 6, 2011

Report Samples and Object Data Source Setting in RDL report

How to set the external file path for an image used in RDL report

  1. add an "image" element to the rdlc report created, set its "Source" property to "External" and its "MIMEType" property to "image/png" if the image file is a png
  2. drag a data field into the "image" element, this data field will contains the [filepath] of the image file, the filepath should be something looks like "file:///C:/temp/image.png" or "file:///c:\\temp\\image.png"
  3. add a reportviewer named rpv to the winform, and in the winform constructor code, add "rpv.LocalReport.EnableExternalImages = true;"

How to embed subreports in a RDL report

  1. Create reports Main.rdlc and Sub1.rdlc, Sub2.rdlc, Main.rdlc will be the main report and Sub1.rdlc and Sub2.rdlc will be the subreports embedded into Main.rdlc, 
  2. add two "Subreport" elements to the Main.rdlc, with each element's reportname field set to "Sub1.rdlc" and "Sub2.rdlc" respectively,
  3. create a winform and add a reportviewer to it, set the report for the reportviewer to be "Main.rdlc", name the reportviewer rpv
  4. open "View Code" on the winform, and in the constructor add "rpv.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);"
  5. add a method "void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)" to the winform code, now create two List<Object> for each subreport in the method, and add "e.DataSources.Add(new ReportDataSource("Accounting_Core_Purchase_MiscPurchaseLine", [List<Object>]));" for each subreport

Tuesday, January 4, 2011

Solving the problem about the autoshrinking of report viewer table

The solution is to put the table in a rectangle element http://stackoverflow.com/questions/1255267/resizing-rdl-report-inside-reportviewer-control-in-asp-net

Get ReportViewer.dll for asp.net deployment

for asp.net that use reportviewer control, during deployment the reportviewer.dll must be copied into the "bin" directory. To do this follow these steps:


  1. open console, and type "cd c:\windows\assembly"
  2. type "cd gac_msil"
  3. type "xcopy microsoft.reportviewer.processingObjectModel c:\temp /i /h /s /r /y"
that's it. you get the reportviewer.dll copied into c:\temp, just copy them into the "bin" directory of your asp.net project