Microsoft Report Viewer Drillthrough using Multiple Data Sources

139 Views Asked by At

The error I'm getting is "A data source instance has not been supplied for the data source 'AssetLatencyCompleteDataSet_fsAssetLatencyComplete'"

I have 2 Data Sources, AssetSummaryDataSet and AssetLatencyCompleteDataSet

I can only select 1 Data instance, I've looked around and it appears that I should be able to add additional data sources for a single report and they would populate within the report viewer control seen here. enter image description here

I have created the DrillThrough handler, however I still get the above error.

How can I add the data source instance I'm missing to the report viewer?

{
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

There are 1 best solutions below

0
Rupesh On BEST ANSWER

You need to change only following line

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

Instead of "fsAssetLatencyComplete" specify "AssetLatencyCompleteDataSet_fsAssetLatencyComplete"