我有一个本地.rdlc报告用于单击按钮显示,但由于某种原因报告仅显示在第二次按钮单击事件中。我不知道为什么报告没有显示在第一次点击按钮上......这是我在按钮的点击事件上调用的函数。SQL Reporting Services报告仅在第二次点击时加载
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;
}
奇怪的是,如果我取消注释行this.ReportViewer.Reset();那么无论我生成的点击次数如何,报告都将永远不会显示出来......是否有人知道这是否正常?如何解决这个问题? 在此先感谢,
但是,您在pageload方法上执行此操作,或者您使用onclick方法执行此操作?你使用什么版本的ReportViewer? –
我通过回发控件调用该方法。我特意从DropDownList_SelectedIndexChanged事件中抽取这个。我正在使用ReportViewer.WebForms版本10.0.0.0。 – m4chine