我有一個本地.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