Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

3.12 Using Untyped Reports with the Viewer

Using Untyped Reports with the Viewer

Untyped reports are referenced by their filename and they are external to the application’s executable code. Open an Untyped report by passing the filename to the ReportSource property of the viewer. In this example, I set the ReportSource property in the Load() event of the page. I also pass it the name of the Employee List report that I created in Chapter 1. For your application you should pass the filename 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 = Server.MapPath("Employee List.rpt")
End Sub

A second way to bind an Untyped report to the viewer is to set the ReportSource property in the DataBindings dialog box. Look at the Property Window for the viewer and at the very top is the DataBindings property. Click on it and then click on the ellipses button to open the DataBindings dialog box.

When the dialog box opens, click on the ReportSource property and then click on the Custom Bindings Expression option. Within the text area enter the report’s full path name and enclose it in quotes. You should also be aware that there is no Browse button for this property. You have to type in the file path exactly.



Figure 3-6. Setting the custom binding expression.
Be careful when entering the report filename in this dialog box. It is a common source of problems. First of all, the file path must be accessible by the report server and you must have permissions. Secondly, always put quotes around the file path string. Otherwise you will get an error when the viewer attempts to open the report.