This is a migrated thread and some comments may be shown as answers.

Groupheader no longer fires ItemDataBinding

4 Answers 135 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 23 Apr 2013, 03:09 PM
I have a report that handles its datasource internally.  The layout requires three sub-reports and rather than have it fire three database calls for every item on the report I've written a stored procedure which returns four data tables (primary report data, and three tables for the sub-reports).  As each of the customers is displayed, I used the GroupHeader ItemDataBinding event to filter the sub-report tables and dynamically set those datasource values to the filtered data.

This worked great in 2012 Q1, but after updating to Q3 the GroupHeader ItemDataBinding event no longer fires.  As a result, my sub-reports are completely blank.

What do I need to do to resolve this issue?  Below is my code:

public string ConnectionString { get; set; }
 
private void Rpt_CustomerAccountsReport_NeedDataSource(object sender, EventArgs e)
{
    try
    {
        if (Report.ReportParameters["MarketListID"].Value == null
            && Report.ReportParameters["BranchID"].Value == null
            && Report.ReportParameters["CustomerGroupID"].Value == null
            && Report.ReportParameters["CustomerID"].Value == null)
        {
            ErrorMsg("Error!  This report cannot be run without parameters.  Please select a Branch, Marketing list or Customer group.");
        }
        else
        {
            SqlData data = new SqlData(ConnectionString);
            // Shared getdataset function
            dsMain = data.GetDataSet("spRpt_CustomerAccountsReport", CommandType.StoredProcedure,
                                     "@EmployeeUserID", Report.ReportParameters["EmployeeUserID"].Value,
                                     "@MarketListID", Report.ReportParameters["MarketListID"].Value,
                                     "@CustomerID", Report.ReportParameters["CustomerID"].Value,
                                     "@BranchID", Report.ReportParameters["BranchID"].Value,
                                     "@CustomerGroupID", Report.ReportParameters["CustomerGroupID"].Value,
                                     "@EmployeeID", Report.ReportParameters["EmployeeID"].Value);
 
            // ** Moving the max record limit to the stored procedure so we can change / make it user configurable without a re-compile
            if (dsMain.Tables[0].Rows.Count > 40000)
            {
                ErrorMsg("Over 40,000 results were returned.  The report cannot render.  Please select more specific criteria.");
            }
            else
            {
                Report.DataSource = dsMain.Tables[0];
            }
 
        } // They provided parameters
    }
    catch (Exception ex)
    {
        ErrorMsg(ex.Message);
    }
}
 
private void GroupHeaderArea1_ItemDataBinding(object sender, EventArgs e)
{
    try
    {
        // Get the section
        Telerik.Reporting.Processing.GroupSection section = (sender as Telerik.Reporting.Processing.GroupSection);
 
        if (section != null)
        {
            // Get the customer ID for this section
            object id = section.DataObject["CustomerID"];
 
            if (id != null)
            {
                int CustID = (int)id;
 
                // Filter out sub-report data
                DataRow[] drContacts = dsMain.Tables[1].Select("CustomerID=" + CustID.ToString());
                DataRow[] drCrossSell = dsMain.Tables[2].Select("CustomerID=" + CustID.ToString());
                DataRow[] drAccounts = dsMain.Tables[3].Select("CustomerID=" + CustID.ToString());
 
                Rpt_CustomerAccountsReportAccountSummary rptAcct = new Rpt_CustomerAccountsReportAccountSummary();
                Rpt_CustomerAccountsReportContacts rptContact = new Rpt_CustomerAccountsReportContacts();
                Rpt_CustomerAccountsReportCrossSell rptCrossSell = new Rpt_CustomerAccountsReportCrossSell();
 
                rptAcct.DataSource = drAccounts;
                rptContact.DataSource = drContacts;
                rptCrossSell.DataSource = drCrossSell;
 
                srContacts.ReportSource = rptContact;
                srCrossSell.ReportSource = rptCrossSell;
                srAccountSummary.ReportSource = rptAcct;

            }
        }
    }
    catch (Exception ex)
    {
        ErrorMsg(ex.Message);
    }
}

4 Answers, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 24 Apr 2013, 03:58 PM
Hi,

We have answered your question in the support ticket. Let us know there whether the suggestion is correct and everything works as expected.

Regards,
Chavdar
the Telerik team

Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.

0
Nick
Top achievements
Rank 1
answered on 10 May 2013, 07:46 PM
was there a solution to this? My ItemDataBinding events are not firing either in header, footer, and detail sections.
0
David
Top achievements
Rank 1
answered on 10 May 2013, 07:52 PM
Yes, apparently if you use out of process sessions it also runs the report elements out of process.  So you have to rebind the events during the report's NeedDataSource event.  But you have to first find the control in order to bring it in process.  Like this:

// Because we run reports out of process, we have to manually rebind all the events we want to use.
this.GroupHeaderArea1 = (Telerik.Reporting.GroupHeaderSection)this.Items.Find(this.GroupHeaderArea1.Name, true)[0];
this.GroupHeaderArea1.ItemDataBinding += GroupHeaderArea1_ItemDataBinding;
0
Nick
Top achievements
Rank 1
answered on 10 May 2013, 08:05 PM
Thanks that did the trick. I had to use the report's ItemDataBinding event instead of NeedDataSource because NeedDataSource wasn't firing either.
Tags
General Discussions
Asked by
David
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
Nick
Top achievements
Rank 1
David
Top achievements
Rank 1
Share this question
or