Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

3.09 Binding to the Web Viewer

Binding Reports to the Web Viewer

After adding a viewer to the web page and setting its properties, the report needs to be bound to the viewer. As mentioned earlier, the easiest way to do this is by using the Smart Tasks panel. But if you wish, you can manually add a CrystalReportSource component to your web page and set its properties manually. This works equally well with both non-embedded and embedded reports.

Using the CrystalReportSource Component on the Viewer

The CrystalReportSource component makes it easy to specify which report the viewer is supposed to display. Add a CrystalReportSource component to the web page by double-clicking on it from the Toolbox (under the Reporting tab). When you add a CrystalReportSource component to your form, it adds it below the viewer. It also has a SmartTasks button which, when clicked, lets you open theConfigure Report Source dialog box. This lets you select which report will be displayed. The dropdown control lists all the reports that are part of your project and it lets you create a new report or browse for an existing report.



Figure 3-8. The Configure Report Source dialog box.

After adding a CrystalReportSource component and setting the report to print, assign it to the viewer using the viewer’sReportSourceID property. When you click on it, there is a drop-down box listing the name of the CrystalReportSource in it.

As a short-cut, you can modify the ReportSourceID property directly and specify the report to print. This automatically creates a new CrystalReportSource component on your web page and attaches it to the viewer.