Resources » Code Snippets » Winforms Controls

ReportViewer with multiple dataset and report parameters


Posted Date: 13-May-2009  Last Updated:   Category: Winforms Controls    
Author: Member Level: Silver    Points: 10



This code is useful in windows application
This code will give you following ideas
1. How to embed rdlc file in report viewer.
2. How to add multiple datasets for report.
3. How to assign values to report parameters.

Not tested for web application.



//Set the report processing mode
this.reportViewer1.ProcessingMode = ProcessingMode.Local;
//Assign report file i.e. rdlc
this.reportViewer1.LocalReport.ReportEmbeddedResource = "GI.ServiceManager.ServiceReport.rdlc";

//Add datasets
this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("ProcessData", Program.CurrentServiceInstrument.Data.tblServiceReportProcessData));
this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("AccessoryData", Program.CurrentServiceInstrument.Data.tblServiceReportAccessoryData));
this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("Summary", Program.CurrentServiceInstrument.Data.tblServiceReportSummary));

//Create the report parameters and assign values to it
ReportParameter[] rParam = new ReportParameter[2];
rParam[0] = new ReportParameter("rpUnitType", Convert.ToString(Program.CurrentServiceInstrument.Data.tblServiceReportSummary.Rows[0]["UnitType"]));
rParam[1] = new ReportParameter("rpSerialNumber", Convert.ToString(Program.CurrentServiceInstrument.Data.tblServiceReportSummary.Rows[0]["SerialNumber"]));

//Set report parameters
this.reportViewer1.LocalReport.SetParameters(rParam);

//Refresh report to render it
this.reportViewer1.RefreshReport();



Did you like this resource? Share it with your friends and show your love!

Responses to "ReportViewer with multiple dataset and report parameters"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Subscribe to Subscribers
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Talk to Webmaster Tony John

    Online Members

    More...
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India