DataSource is empty before rendering report

0 Answers 164 Views
DataSources Rendering Report Viewer - ASP.NET
csst
Top achievements
Rank 1
csst asked on 25 Apr 2022, 04:08 PM

I'm generating a report, getting the data from a sproc. I assigned the result of the sproc to Data Source  of my report, and I'm able to et data when binding the report and tables, but before rendering the report the Data Source is deleted and not data is shown in the report. 


 Private Sub EmployeeComplianceStatement_NeedDataSource(sender As Object, e As EventArgs) Handles Me.NeedDataSource
        Dim ContractID As Integer? = Me.ReportParameters("ContractID").Value
        Dim EmployeeID As Integer = Me.ReportParameters("EmployeeID").Value
        Dim StartMonth As Integer = Me.ReportParameters("StartMonth").Value
        Dim StartYear As Integer = Me.ReportParameters("StartYear").Value
        Dim EndMonth As Integer = Me.ReportParameters("EndMonth").Value
        Dim EndYear As Integer = Me.ReportParameters("EndYear").Value
        DS = EmployeeBenefitsManager.GetEmployeeBenefitsCompliance(ContractID, EmployeeID, StartMonth, StartYear, EndMonth, EndYear)
        Dim pageHeader = TryCast(Report.Items.Find("pageHeaderSection1", True)(0), Telerik.Reporting.PageHeaderSection)
        Dim txtNodata = TryCast(pageHeader.Items.Find("txtNoData", True)(0), Telerik.Reporting.TextBox)
        If DS.Length = 0 Then
            txtNodata.Visible = True
        Else
            txtNodata.Visible = False
        End If
        Report.DataSource = DS
    End Sub
Private Sub Table1_NeedDataSource(sender As Object, e As EventArgs)
        Dim Table1 As Telerik.Reporting.Processing.Table = DirectCast(sender, Telerik.Reporting.Processing.Table)
        Table1.DataSource = DS
    End Sub

    Private Sub Table2_NeedDataSource(sender As Object, e As EventArgs)
        Dim Table2 As Telerik.Reporting.Processing.Table = DirectCast(sender, Telerik.Reporting.Processing.Table)
        Table2.DataSource = DS
    End Sub

    Private Sub Table3_NeedDataSource(sender As Object, e As EventArgs)
        Dim Table3 As Telerik.Reporting.Processing.Table = DirectCast(sender, Telerik.Reporting.Processing.Table)
        Table3.DataSource = DS
    End Sub


Dimitar
Telerik team
commented on 28 Apr 2022, 08:30 AM

From what I can see,  in the EmployeeComplianceStatement_NeedDataSource event, the Report is accessed directly through the Report.DataSource property. This is not expected to work because, in current releases, modifying report items in the report event should change the Telerik.Reporting.Processing element sent in the sender object, exactly what is done with the tables in the other 3 NeedDataSource events.

Basically, the sender needs to be DirectCasted to Telerik.Reporting.Processing.Report type and then you may edit the DataSource of the processing report.

For more information, please read the Changes on items in report events are not applied KB article.

No answers yet. Maybe you can help?

Tags
DataSources Rendering Report Viewer - ASP.NET
Asked by
csst
Top achievements
Rank 1
Share this question
or