使用多个数据源的Microsoft Report Viewer钻取

时间:2016-10-07 15:43:49

标签: c# winforms reportviewer2008

我得到的错误是"尚未为数据源提供数据源实例' AssetLatencyCompleteDataSet_fsAssetLatencyComplete'"

我有2个数据源,AssetSummaryDataSet和AssetLatencyCompleteDataSet

我只能选择1个数据实例,我环顾四周,似乎我应该可以为单个报告添加其他数据源,并且它们将填充在此处显示的报告查看器控件中。 enter image description here

我创建了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();
    }
}

}

1 个答案:

答案 0 :(得分:1)

您只需要更改以下行

localReport.DataSources.Add(new ReportDataSource("fsAssetLatencyComplete", (object)assetLatencyCompleteDataSet.fsAssetLatencyComplete));

而不是" fsAssetLatencyComplete"指定" AssetLatencyCompleteDataSet_fsAssetLatencyComplete"