使用多个数据源的 Microsoft Report Viewer 钻取
Microsoft Report Viewer Drillthrough using Multiple Data Sources
我得到的错误是 "A data source instance has not been supplied for the data source 'AssetLatencyCompleteDataSet_fsAssetLatencyComplete'"
我有 2 个数据源,AssetSummaryDataSet 和 AssetLatencyCompleteDataSet
我只能 select 1 个数据实例,我环顾四周,似乎我应该能够为单个报告添加额外的数据源,它们将填充在此处看到的报告查看器控件中.
我已经创建了 DrillThrough 处理程序,但是我仍然收到上述错误。
如何将缺少的数据源实例添加到报表查看器?
{
public partial class frmAssetSummaryRpt : Form
{
public frmAssetSummaryRpt()
{
InitializeComponent();
}
private void frmAssetSummaryRpt_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'assetSummaryDataSet.fsAssetRecoverySummaryByClientWO' table. You can move, or remove it, as needed.
this.fsAssetRecoverySummaryByClientWOTableAdapter.Fill(this.assetSummaryDataSet.fsAssetRecoverySummaryByClientWO);
reportViewer1.Drillthrough += new DrillthroughEventHandler(reportDrillthroughEventHandler);
this.reportViewer1.RefreshReport();
}
void reportDrillthroughEventHandler(object sender, DrillthroughEventArgs e)
{
LocalReport localReport = (LocalReport)e.Report;
localReport.DataSources.Add(new ReportDataSource("fsAssetLatencyComplete", (object)assetLatencyCompleteDataSet.fsAssetLatencyComplete));
}
private void button1_Click(object sender, EventArgs e)
{
frmAssetLatencyFullRpt AssetLatencyFullReport = new frmAssetLatencyFullRpt();
AssetLatencyFullReport.Show();
}
}
}
您只需更改以下行
localReport.DataSources.Add(new ReportDataSource("fsAssetLatencyComplete", (object)assetLatencyCompleteDataSet.fsAssetLatencyComplete));
而不是 "fsAssetLatencyComplete" 指定 "AssetLatencyCompleteDataSet_fsAssetLatencyComplete"
我得到的错误是 "A data source instance has not been supplied for the data source 'AssetLatencyCompleteDataSet_fsAssetLatencyComplete'"
我有 2 个数据源,AssetSummaryDataSet 和 AssetLatencyCompleteDataSet
我只能 select 1 个数据实例,我环顾四周,似乎我应该能够为单个报告添加额外的数据源,它们将填充在此处看到的报告查看器控件中.
我已经创建了 DrillThrough 处理程序,但是我仍然收到上述错误。
如何将缺少的数据源实例添加到报表查看器?
{
public partial class frmAssetSummaryRpt : Form
{
public frmAssetSummaryRpt()
{
InitializeComponent();
}
private void frmAssetSummaryRpt_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'assetSummaryDataSet.fsAssetRecoverySummaryByClientWO' table. You can move, or remove it, as needed.
this.fsAssetRecoverySummaryByClientWOTableAdapter.Fill(this.assetSummaryDataSet.fsAssetRecoverySummaryByClientWO);
reportViewer1.Drillthrough += new DrillthroughEventHandler(reportDrillthroughEventHandler);
this.reportViewer1.RefreshReport();
}
void reportDrillthroughEventHandler(object sender, DrillthroughEventArgs e)
{
LocalReport localReport = (LocalReport)e.Report;
localReport.DataSources.Add(new ReportDataSource("fsAssetLatencyComplete", (object)assetLatencyCompleteDataSet.fsAssetLatencyComplete));
}
private void button1_Click(object sender, EventArgs e)
{
frmAssetLatencyFullRpt AssetLatencyFullReport = new frmAssetLatencyFullRpt();
AssetLatencyFullReport.Show();
}
}
}
您只需更改以下行
localReport.DataSources.Add(new ReportDataSource("fsAssetLatencyComplete", (object)assetLatencyCompleteDataSet.fsAssetLatencyComplete));
而不是 "fsAssetLatencyComplete" 指定 "AssetLatencyCompleteDataSet_fsAssetLatencyComplete"