So I'm new to Telerik, and have been struggling getting a NeedDataSource event to fire in an ASP .NET web application with the latest version of Reporting, Q2 2014 (8.1.14.618). Interestingly, the code I'm about to post works fine in the much older version (3.1.9.701) and I'm at a loss as to what has changed and why the code that used to work is broken now.
So in our aspx page we have a simple ReportViewer Control
The code behind file goes and gets data when the page loads:
And then the code generated from the designer looks like this, CustomReport1.cs:
For line 25, CustomCollection is just a list of BLL objects. The craziest thing for me is that when I run with the old version I can hit breakpoints inside tbl_NeedDataSource function. However, with the new Telerik controls I am unable to hit anything in the tbl_NeedDataSource function. I'm wondering what may have gotten lost in translation to the newer controls, maybe there's some kind of mechanism that became obsolete between those two versions that would cause the "wiring" not to work. Or maybe there's just a better way to do this now :) Any thoughts or suggestions would be helpful. Thanks in advance!
So in our aspx page we have a simple ReportViewer Control
<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" style="margin: 0px;"> <form id="form1" runat="server"> <div style="height: 100%;"> <telerik:ReportViewer ID="ReportViewer1" runat="server" width="100%" height="100%"> </telerik:ReportViewer> </div> </form></body>The code behind file goes and gets data when the page loads:
01.protected void Page_Load(object sender, EventArgs e)02.{03. if (!IsPostBack)04. {05. LoadData();06. }07.}08. 09.private void LoadData()10.{11. Page.Title = "Report Title";12. 13. ReportBook reportBook = new ReportBook();14. 15. CustomReport1 report = new CustomReport1();16. CustomReport2 report2 = new CustomReport2();17. CustomReportData data = new CustomReportData(_Id);18. report.DataSource = data;19. report2.DataSource = data;20. 21. reportBook.Reports.Add(report);22. reportBook.Reports.Add(report2);23. 24. this.ReportViewer1.Report = reportBook;25.}And then the code generated from the designer looks like this, CustomReport1.cs:
01.public partial class CustomReport : Telerik.Reporting.Report02.{03. public CustomReport()04. {05. /// <summary>06. /// Required for telerik Reporting designer support07. /// </summary>08. InitializeComponent();09. 10. //create event that will set the data source for the table11. tbl.NeedDataSource += new EventHandler(tbl_NeedDataSource);12. }13. 14. /// <summary>15. /// Handles the NeedDataSource event of the tbl control.16. /// </summary>17. /// <param name="sender">The source of the event.</param>18. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>19. void tbl_NeedDataSource(object sender, EventArgs e)20. {21. //In order to programmatically set the table, we need to use the processing table22. Telerik.Reporting.Processing.Table table = ((Telerik.Reporting.Processing.Table)sender);23. 24. //set the data source of the table25. table.DataSource = ((CustomReportData)table.Report.DataSource).CustomCollection;26. }27.} For line 25, CustomCollection is just a list of BLL objects. The craziest thing for me is that when I run with the old version I can hit breakpoints inside tbl_NeedDataSource function. However, with the new Telerik controls I am unable to hit anything in the tbl_NeedDataSource function. I'm wondering what may have gotten lost in translation to the newer controls, maybe there's some kind of mechanism that became obsolete between those two versions that would cause the "wiring" not to work. Or maybe there's just a better way to do this now :) Any thoughts or suggestions would be helpful. Thanks in advance!