locked
Problem with Drillthrough naming & cached/invalid ReportDataSource RRS feed

  • Question

  • I'm trying to get basic Drillthrough to work with Webforms and am running into two problems:

    1. When I execute the drillthrough method I get an error that I need a datasource instance for a datasource that I removed and is no longer valid. I read on this forum in the posting:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=212322&SiteID=1

    that this is a bug with VS 2005 related to the absence of ReportViewer.Reset() in Webforms. The workaround being to create a new ReportViewer instance. I'm not sure if I'm doing that correctly in my code sample below.

    2. My second problem is that when adding a ReportDatasource to my drillthrough report, I'm not exactly sure how to reference my dataset and datasources. The naming convention is unclear to me, and the gotreportviewer.com samples didn't really help.

    Here's my setup:
    My application has a main report that uses a dataset & tableadapter that uses a stored procedure to get the a list of Employers. No problem here. When you click on the EmployeeID cell in the main report I want to drillthrough and display the details of the Employee. The gotreportviewer.com drillthrough example did this very thing but read an xml file instead of queried a db -- I wasn't able to rework the sample for a db query.

    I will get the Employee details by passing the EmployeeID to a GetEmployeeDetails stored proc.

    My dataset setup is:
    Name: EmpDetails.xsd
    Table: MyReport_GetEmpDetails
    TableAdapter: MyReport_GetEmpDetailsTableAdapter
    Methods: Fill, GetData(@EmpID)
    Stored Proc: GetEmployeeByID

    Given the above info, how do I correctly reference/name my dataset and datasource in my drillthrough method?? See code sample below. The declarative aspect sof the drillthrough report are setup fine, it's my drillthrough method that I'm unclear about.

    Here's my drillthrough method (that isn't working, I get a blank drillthrough screen):

    protected void ReportViewer1_Drillthrough(object sender, DrillthroughEventArgs e)
    {

    // Create a new instance of ReportViewer
    ControlCollection
    coll = ReportViewer1.Parent.Controls;
    int
    oldIndex = coll.IndexOf(ReportViewer1);
    ReportViewer newReportViewer1 = new ReportViewer
    ();
    coll.AddAt(oldIndex, newReportViewer1);
    coll.Remove(ReportViewer1); 

    DataSet ds = new DataSet("EmpDetails");

    LocalReport drillthroughReport = (LocalReport)e.Report;
    ReportDataSource dataSource = new ReportDataSource("EmpDetailsDataSet_EmpDetails", dataSet.Tables[0]
    );
    drillthroughReport.DataSources.Add(dataSource);

    }

    Thank you for this excellent tool and forum.

    Any help is greatly appreciated!

    Tuesday, November 7, 2006 1:21 PM