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

Blank report

1 Answer 144 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
don
Top achievements
Rank 1
don asked on 17 Feb 2010, 07:28 PM
I am trying to use the report viewer to display reports, i am setting the property reportviewer.report = rpt, based on the report the user wants to display, however i always get a blank report. Any suggestions, help?

This is the button that calls the report

Private

 

Sub btnQAChecklist_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQAChecklist.Click

        Dim rpt As New ReconChecklistRpt(_planToPlanUpload.PlanToPlanUploadId)  

        Dim frm As New PDRSReportViewer(rpt)  

        frm.Show()

 

End Sub

This is the code for the report.

Imports

 

System.ComponentModel

 

 

 

Imports System.Drawing

 

 

 

Imports System.Windows.Forms

 

 

 

Imports Telerik.Reporting

 

 

 

Imports Telerik.Reporting.Drawing

 

 

 

Imports System.Data.SqlClient

 

 

 


Partial
Public Class ReconChecklistRpt

 

 

 

 

Inherits Telerik.Reporting.Report

 

 

 

 

 

        Private _PlanToPlanUploadId As Integer

    

 

    Public Sub New()

 

 
               InitializeComponent()

               _PlanToPlanUploadId = 5198

 

 

                Me.DataSource = Nothing

 

 

 

        End Sub

 

 

 

 

 

 

    Public Sub New(ByVal PlanToPlanUploadId As Int32)

 

        _PlanToPlanUploadId = PlanToPlanUploadId

 

        Me.DataSource = Nothing 

 

 

    End Sub

 

 

 

 

 

    Private Sub ReconChecklistRpt_NeedDataSource(ByVal sender As Object, ByVal e As System.EventArgs) HandlesMe.NeedDataSource

 

 

    Dim cn As New SqlConnection(My.Settings.ConnectionString) 

 

    Dim da As New SqlDataAdapter("rpt_QACheckListByPlanToPlanUploadId", cn)

 

 

    da.SelectCommand.CommandType = CommandType.StoredProcedure

    da.SelectCommand.Parameters.AddWithValue(

"@PlanToPlanUploadId", _PlanToPlanUploadId)

 

 

 

    Report.DataSource = da

 

    End Sub

 

End

 

Class

 

 

 

 

 

This is the report viewer form

 

Public

 

Class PDRSReportViewer

 

 

 

 

    Public Sub New()

' This call is required by the Windows Form Designer. 

 

 

        InitializeComponent()

' Add any initialization after the InitializeComponent() call.

 

 

 

    End Sub

 

 

 

    Public Sub New(ByVal report As Telerik.Reporting.IReportDocument)

 

        InitializeComponent()

 

 

        Me.ReportViewer.Report = report

 

 

    End Sub

 

 

 

 

 

 

    Private Sub PDRSReportViewer_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

 

 

        Me.ReportViewer.RefreshReport()

 

 

    End Sub

 

End

 

Class

 

 

 

 

 

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 18 Feb 2010, 11:40 AM
Hi Don,

We kindly ask you to use just one support channel to contact us. Posting the same questions numerous times slows down our response time because we will need to review and address two tickets instead of one. Moreover threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread.
Your question has already been answered in the other thread you've opened, but here is the answer in case somebody encounters the same problem:

"This is a common mistake when setting DataSource through code. As the Report Life Cycle topic explains the Telerik Reporting engine works with two object:
  • the report definition - "the Report" - is  a class derived from Telerik.Reporting.Report; usually created with the help of the Report Designer or programmatically. Its only purpose is to describe how the report will look like. You may think of the reports as data grids - when you put the data grid on a form, this is actually the description/template of the grid which defines how the data will be displayed, appearance and behavior. This is exactly what the report definition is for. (Although it is a .NET class now, we have plans to move it to the simpler XML description)
  • the report instance (an object type Telerik.Reporting.Processing.Report) is the report definition merged with the data from the data source.
Both objects look similar (and sometimes both are called "Reports", which is incorrect), but are not the same as you can guess from their namespaces.
You can find more info about the report definition and report processing objects in Understanding Events
In short, as the Adding a Data Source through NeedDataSource report event help article shows, you should get reference to the processing report object and set the DataSource to it e.g.:

instead of:

Report.DataSource = da 

should be

TryCast(sender, Telerik.Reporting.Processing.Report).DataSource = da"
help topic.

Thank you for your understanding.

Regards,
Steve
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
General Discussions
Asked by
don
Top achievements
Rank 1
Answers by
Steve
Telerik team
Share this question
or