Finally, you can choose to add a strongly typed report component, which probably has the simplest binding method of all. First of all, add the report that you wish to bind to your project. In our case, this will be sales_graph.rpt. To create a strongly typed ReportDocument component, drag the ReportDocument component onto your Web Form. (The code for this Web Form is available in the code download for the chapter as web_viewer_stronglytyped.) This will open the dialog shown in Figure 5-12 and allow you to create a strongly typed report.
You will then see the same dialog as before, with a drop-down list of all of the available reports that are in your project. Select an existing report to create a strongly typed ReportDocument. Now, insert the CrystalDecisions.CrystalReports.Engine namespace into the project using the Properties page, as we did previously, drag on a CrystalReportViewer, and we're set. From that point, we just need to set the ReportSource property in the Page_Init event once more:
CrystalReportViewer1.ReportSource = sales_graph1
(where sales_graph1 is the name automatically assigned to the ReportDocument component when you added it to your form).
Was this article helpful?