I have a local .rdlc report rigged to show on a button click, but for some reason the report only shows up on the 2nd button click event. I have no idea why the report doesn't show on the first button click... This is the function I call on the click event of the button.
private void ShowReport(string accountingCompanyId, string companyId, string approvalUnitId, DateTime startDate, DateTime finishDate, string supplierId,
string documentNumber, string documentType, string documentState, string costCenterId, string chargingKeyId,
string dim1Value, string dim1Description, string dim1Id, string dim2Value, string dim2Description, string dim2Id,
string dim3Value, string dim3Description, string dim3Id, bool showDetails) {
//this.ReportViewer1.Reset();
//Set report mode for local processing.
this.ReportViewer1.ProcessingMode = ProcessingMode.Local;
ISettingsReader settingsReader = SettingsReaderFactory.Instance.CreateSettingsReader();
this.ReportViewer1.LocalReport.ReportPath = settingsReader.GetSetting("ReportViewer", "FinancialReportPath" + (showDetails ? "" : "Small"), true, null);
ReportsBL reports = new ReportsBL();
// Clear out any previous datasources.
this.ReportViewer1.LocalReport.DataSources.Clear();
// Load the company dataSource.
DataTable company = reports.GetCompanyDataSet(accountingCompanyId).Tables[0];
ReportDataSource dataSourceCompany = new ReportDataSource(company.TableName, company);
this.ReportViewer1.LocalReport.DataSources.Add(dataSourceCompany);
// Load the dataSource.
DataTable report = reports.GetReportFinanceiroSmallDataSet(companyId, startDate, finishDate, chargingKeyId, costCenterId, documentNumber, documentType, dim1Value, dim2Value, dim3Value, dim1Id, dim2Id, dim3Id, supplierId, approvalUnitId, documentState, accountingCompanyId).Tables[0];
ReportDataSource dataSourceReport = new ReportDataSource(report.TableName, report);
this.ReportViewer1.LocalReport.DataSources.Add(dataSourceReport);
this.ReportViewer1.LocalReport.Refresh();
this.pnlReport.Visible = true;
}
Strangely, if I uncomment the line this.ReportViewer.Reset(); then the report will never show up regardless of the number of clicks I generate... Does anybody know if this is normal? How can work around the problem? Thanks in advance,
I guess the problem might be that the click event is fired after the page is rendered. Try calling the method in the Page_Load
event.
protected void Page_Load(object sender, EventArgs e)
{
if (IsCallback)
{
ShowReport(
// params
);
}
}
If that works, you know it has something to do with the order of execution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With