Share via


Binding to a File Directory Path Through the Properties Window

Object Model

This report binding scenario uses the CrystalReportViewer (see Report Binding with CrystalReportViewer Object Model.)

Location of Reports

Reports are stored in a file directory.

Description

This is an alternative version of the simplest report binding scenario, Binding to a File Directory Path in Code. You bind a report in the file directory by its path string to the CrystalReportViewer control, but set the assignment in the Properties window, either directly to the ReportSource property or to the DataBindings>ReportSource property.

For a Web project, the report path string is inserted directly into the HTML of the ASPX page, rather than into the code in the code-behind class.

Pros

Cons

  • For a Web application, because binding occurs in the HTML page, you must call the DataBind() method for the CrystalReportViewer control in the code-behind class.

    Note

    This limitation was removed in Crystal Reports for Visual Studio 2005. For more information, see Automatic Data Binding to Crystal Reports From the Properties Window.

  • Limited distribution: reports typically stay on the same machine as the application, due to the complications involved when permissions are granted to the ASPNET user account to access another machine on the network.

  • Limited object model: this binding scenario offers only the limited object model that is part of the CrystalReportViewer. See Which Object Model Should I Use?.

To bind to a file directory path using the Properties window

  1. Create a new Web or Windows project.

  2. From the Toolbox, drag a CrystalReportViewer control onto the Web or Windows Form.

  3. Click the CrystalReportViewer control to select it.

  4. From the Properties window, assign a file directory path string to the ReportSource property.

> [!NOTE]
> <P>The file directory path points to the sample reports in Visual Studio. For the full path to the sample reports in your version of Crystal Reports, see <A href="ms225622(v=vs.90).md">Sample Reports' Directory</A>.</P>


Because of the design time preview feature, the report is displayed in preview mode.

    C:\Program Files\Microsoft Visual Studio 9.0\Crystal
    Reports\Samples\En\Reports\Feature Examples\Hierarchical
    Grouping.rpt
  1. To view the report, build and run your project.

See Also