我有一个本地.rdlc报告操纵,以显示在一个按钮点击,但由于某些原因,报告只显示在第二个按钮点击事件。我不知道为什么在第一次点击按钮时报告没有显示出来...这是我在按钮的单击事件上调用的函数。
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()行的注释,那么无论我生成多少次点击,报表都不会显示出来……有人知道这是不是正常吗?如何解决这个问题?提前谢谢你,
发布于 2013-04-05 00:19:44
我猜问题可能是单击事件在页面呈现后触发。尝试在Page_Load事件中调用该方法。
protected void Page_Load(object sender, EventArgs e)
{
if (IsCallback)
{
ShowReport(
// params
);
}
}如果这行得通,你就知道它与执行的顺序有关。
https://stackoverflow.com/questions/15747854
复制相似问题