Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

3.13 Using Strongly-Typed Reports with the Viewer

Using Strongly-Typed Reports with the Viewer

Strongly-Typed reports are referenced by passing an instance of the report class to ReportSource property of the viewer. In this example I pass a new instance of the Employee_List class to the ReportSource property. For your application you would pass the class name of the report you want to display.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CrystalReportViewer1.ReportSource = New Employee_List
End Sub
When using Untyped or Strongly-Typed reports, don’t call the viewer’s DataBind() method. If you call DataBind() after setting the ReportSource property, the ReportSource value is reset and the report won’t display. I see this mistake a lot because people assume that calling the DataBind() method is a requirement for using the viewer. This isn’t the case at all. It’s only necessary if you set properties within the DataBindings dialog box. If you do need to call the DataBind() method, call it prior to setting the ReportSource property in code.