1. I want to remove hardcoe from this line-
report.ReportPath = @"F:\Projects\SaleSlip.rdlc"
How will it work after deploying my project to other drvie?
You could copy your report files to the application path.
You can achieve this when you build your project:
a. Locale the "Copy to Output Directory" property of the report file.
b. Change it to "Copy always".
Then, use a relative url:
report.ReportPath = "reportName.rdlc";
2. I want to load a report this way.
reportViewer.LocalReport = report;//I want to load report to reportviwer
The LocalReport property of the ReportViewer is readonly.
You could do this:
SaleSlipViewer frmSaleSlipViwer = new SaleSlipViewer();
ReportViewer reportViewer = frmSaleSlipViwer.rpvSaleSlipVeiwer;
LocalReport report = reportViewer.LocalReport;
report.ReportPath = @"F:\Projects\SaleSlip.rdlc"
report.DataSources.Add(new ReportDataSource("SaleSlipData", dtAddItems));
report.DataSources.Add(new ReportDataSource("SaleSlipPaymentData", dtPaymentCollection));
switch (strOption)
{
case "Print":
SendToPrinter(report);
break;
case "Preview":
reportViewer.Clear();
reportViewer.RefreshReport();
break;