Subscribe to Subscribers
Talk to Webmaster Tony John

Online Members

Pawan Awasthi
More...


Resources » Code Snippets » Winforms Controls

ReportViewer with multiple dataset and report parameters


Posted Date:     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.


    Next Resource: Creating round buttons in WPF
    Previous Resource: Combo Box showing full text
    Return to Resources
    Post New Resource
    Category: Winforms Controls


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    ReportViewer and multiple dataset  .  Add Report Parameters  .  



    Follow us on Twitter: https://twitter.com/dotnetspider

    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.