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:
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);
}
}