locked
drillthrough event not getting fired in my aspx page RRS feed

  • Question

  • User-1528094326 posted

    Not sure what I am missing, but its probably something stupid and simple, like it usually is! :)

    I have a page with a ReportViewer control that I am setting dynamically based on the type of report the user has requested. Here is my source code in question:

    if (reportType == "Detailed")
                {
                    if (!IsPostBack)
                    {
                        Reports_Orders_By_Surgery_Center_Detailed Orders = new Reports_Orders_By_Surgery_Center_Detailed();
                        ReportViewer1.ProcessingMode = ProcessingMode.Local;
                        ReportViewer1.LocalReport.ReportPath = "Main/Admin/Reports/Templates/OrdersBySurgeryCenterDetailed.rdlc";
                        ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Reports_Orders_By_Surgery_Center_Detailed_Data", Orders.GetData(companyID, startDate, endDate)));
                        ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(OrdersBySurgeryCenterDetailed_SubreportProcessing);
                        ReportViewer1.Drillthrough += new DrillthroughEventHandler(OrdersBySurgeryCenterDetailed_Drillthrough);
                        ReportViewer1.LocalReport.EnableHyperlinks = true;
                        bool temp = ReportViewer1.LocalReport.IsDrillthroughReport;
                        ReportViewer1.LocalReport.Refresh();
                    }
                }


     

     

        protected void OrdersBySurgeryCenterDetailed_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
        {
            Reports_Orders_Items_By_Surgery_Center_Detailed OrderItems = new Reports_Orders_Items_By_Surgery_Center_Detailed();
            int[] OrderNumbers = GetOrderNumbers();
            e.DataSources.Add(new ReportDataSource("Reports_Orders_Items_By_Surgery_Center_Detailed_Data", OrderItems.GetData(OrderNumbers)));
        }
    
        protected void OrdersBySurgeryCenterDetailed_Drillthrough(object sender, DrillthroughEventArgs e)
        {
            // just something to check and see if the drill through event fires.
            bool temp = false;
            if (temp)
            {
                successLabel.Text = "yay!";
            }
        }

    Problem I am having is that no matter what I do or try, the Drillthrough event never fires no matter what.

    I have my parent report set up with proper text box properties that tell it to Jump To another report and pass parameters, but it just doesn't fire the event. The IsDrillThrough property is always false as well when I check it.

     

    What am I missing?

     

    Thanks guys


     

    Tuesday, October 20, 2009 2:55 PM

Answers

  • User-1734134863 posted

    Hi,

    Based on my test, please remove "if (!IsPostBack)" block  , then test it.

    For example:

      protected void Page_Load(object sender, EventArgs e)
        {     
                ReportViewer1.ProcessingMode = ProcessingMode.Local;
                ReportViewer1.LocalReport.ReportPath = "Report2.rdlc";
                ReportViewer1.Drillthrough += new Microsoft.Reporting.WebForms.DrillthroughEventHandler(ReportViewer1_Drillthrough);     
        }

        void ReportViewer1_Drillthrough(object sender, Microsoft.Reporting.WebForms.DrillthroughEventArgs e)
        {
          

        }

    For more information about "Configuring Subreports and Drillthrough Reports", please refer to

    http://msdn.microsoft.com/en-us/library/ms251765(VS.80).aspx

     

     

    Please feel free to let me know if I’ve misunderstood anything.

     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 22, 2009 11:46 PM
  • User-1528094326 posted

    YAY ITS FIXED!!!! Ok I had to play with it alot, and then the post above was a key factor, and looking at some articles by Microsft on how to do it.

    Basically I had all my code inside an (!IsPostBack) block, which it had to be in order to display my report correctly, but what I didn't know is that I did NOT want my line to add the drillthrough event handler in there. That had to be OUTSIDE of the IsPostBack block. so now my code looks like this and it works fine...

     

    if (reportType == "Detailed")
    {
        if (!IsPostBack)
        {
            // Setup instance of the detailed orders by surgery center report class
            Reports_Orders_By_Surgery_Center_Detailed Orders = new Reports_Orders_By_Surgery_Center Detailed();
            
            // set the reportviewer properties
            ReportViewer1.LocalReport.ReportPath = "Main/Admin/Reports/Templates/OrdersBySurgeryCenterDetailed.rdlc";
            ReportViewer1.LocalReport.DataSource.Add(new ReportDataSource("Reports_Orders_By_Surgery_Center_Detailed_Data", Orders.GetData(companyID, startDate, endDate)));
            ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(OrdersBySurgeryCenterDetailed_SubreportProcessing);
            }
        ReportViewer1.Drillthrough += new DrillthroughEventHandler(OrdersBySurgeryCenterDetailedDrillthrough);
    }

     

    Notice the ReportViewer1.Drillthrough add on there is OUTSIDE of the if (!IsPostBack) block.

    I hope this helps anyone else having this problem, as I couldn't find a single solution on the net for it, but had to keep jimmy rigging until I could put all the pieces together.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 26, 2009 2:53 PM

All replies

  • User-1528094326 posted

    No one has any suggestions even? 

    Wednesday, October 21, 2009 12:39 PM
  • User-1734134863 posted

    Hi,

    Based on my test, please remove "if (!IsPostBack)" block  , then test it.

    For example:

      protected void Page_Load(object sender, EventArgs e)
        {     
                ReportViewer1.ProcessingMode = ProcessingMode.Local;
                ReportViewer1.LocalReport.ReportPath = "Report2.rdlc";
                ReportViewer1.Drillthrough += new Microsoft.Reporting.WebForms.DrillthroughEventHandler(ReportViewer1_Drillthrough);     
        }

        void ReportViewer1_Drillthrough(object sender, Microsoft.Reporting.WebForms.DrillthroughEventArgs e)
        {
          

        }

    For more information about "Configuring Subreports and Drillthrough Reports", please refer to

    http://msdn.microsoft.com/en-us/library/ms251765(VS.80).aspx

     

     

    Please feel free to let me know if I’ve misunderstood anything.

     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 22, 2009 11:46 PM
  • User-1528094326 posted

    Hey thanks very much for the reply.

    I actually tried that very thing earlier and found the same result when I created a new website to test this problem alone. In my test website I used the same code and the same reports, and it works perfectly so I'm not sure whats wrong.

    Basically in my actual application I need it working in, after fixing the code it now at least gives me an error saying it cannot find a data source for it, which it obviously cannot because that needs to be assigned in the Drillthrough event, but it still never fires.

    I've been working on it now for the past 3 days and still no avail. I'm not sure whats wrong with it, because it works fine in my test app, but not in my actual app.

    Do you have any ideas on how I can try and debug it further?

    Friday, October 23, 2009 12:21 AM
  • User-1528094326 posted

    I was able to find another discrepency. If I hardcode the Drillthrough event in the aspx page it works fine, but if I try and do ReportViewer1.Drillthrough += (new Drillthrough method here) then that event doesn't fire. Any thoughts? 

    Monday, October 26, 2009 10:42 AM
  • User-1528094326 posted

    YAY ITS FIXED!!!! Ok I had to play with it alot, and then the post above was a key factor, and looking at some articles by Microsft on how to do it.

    Basically I had all my code inside an (!IsPostBack) block, which it had to be in order to display my report correctly, but what I didn't know is that I did NOT want my line to add the drillthrough event handler in there. That had to be OUTSIDE of the IsPostBack block. so now my code looks like this and it works fine...

     

    if (reportType == "Detailed")
    {
        if (!IsPostBack)
        {
            // Setup instance of the detailed orders by surgery center report class
            Reports_Orders_By_Surgery_Center_Detailed Orders = new Reports_Orders_By_Surgery_Center Detailed();
            
            // set the reportviewer properties
            ReportViewer1.LocalReport.ReportPath = "Main/Admin/Reports/Templates/OrdersBySurgeryCenterDetailed.rdlc";
            ReportViewer1.LocalReport.DataSource.Add(new ReportDataSource("Reports_Orders_By_Surgery_Center_Detailed_Data", Orders.GetData(companyID, startDate, endDate)));
            ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(OrdersBySurgeryCenterDetailed_SubreportProcessing);
            }
        ReportViewer1.Drillthrough += new DrillthroughEventHandler(OrdersBySurgeryCenterDetailedDrillthrough);
    }

     

    Notice the ReportViewer1.Drillthrough add on there is OUTSIDE of the if (!IsPostBack) block.

    I hope this helps anyone else having this problem, as I couldn't find a single solution on the net for it, but had to keep jimmy rigging until I could put all the pieces together.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 26, 2009 2:53 PM
  • User-1759751659 posted

    Thanks it worked. i forgot to put condition for checking POSTBACK :)

    Friday, April 29, 2011 3:54 AM