我正在使用以下代码更改在按钮单击事件的报表查看器控件中显示的报表。
private void ReinitializeViewer(string tsReport)
{
ReportDataSource ReportDataSourceX = new ReportDataSource();
this.PurchaseReprotViewer.Reset();
this.PurchaseReprotViewer.LocalReport.ReportEmbeddedResource = tsReport;
if (tsReport.Contains("Rpt_PurchaseInvoice.rdlc"))
{
this.purchaseTableAdapter.Fill(this.gmsDataSet.purchase);
ReportDataSourceX.Name = "PurchaseInvoiceDataSet";
ReportDataSourceX.Value = this.gmsDataSet.Tables["purchase"];
}
else
{
ReportDataSourceX.Name = "DataSet1";
// ReportDataSourceX.Value = Me.MyBindingSource1
}
this.PurchaseReprotViewer.LocalReport.DataSources.Add(ReportDataSourceX);
//this.purchaseTableAdapter.Fill(this.gmsDataSet.purchase);
this.PurchaseReprotViewer.RefreshReport();
}
private void Cmd_PurchaseInvoices_Click(object sender, EventArgs e)
{
ReinitializeViewer("Rpt_PurchaseInvoice.rdlc");
}
但是我在输出中遇到了一个奇怪的错误。
我无法确定上述代码中出了什么问题。任何帮助表示赞赏。提前致谢。