Viewing Reports in Web Forms
To view a report in a Web Form, you go through the same process of adding a new report to your ASP.NET applications and designing the report using the Report Expert. After you've designed the report, you must add the CrystalReportViewer control from the Web Forms Toolbox tab. At this point, things change slightly.Earlier, you saw how to programmatically load a report at runtime. The method of loading a report into the Web Form viewer control is the same. If you want to set the ReportSource property at design time, you must select the DataBindings property from the Properties window of the report viewer. Figure 18.21 demonstrates the DataBindings dialog box for a report viewer. Notice the ReportSource propertyI've entered the path to a valid report file that I created.
Figure 18.21. Setting the DataBindings of a Web report at design time.

When the ReportSource property is set, a report appears in the Web Form with phony data, as Figure 18.22 demonstrates.
Figure 18.22. A report loaded into the Web Form viewer.

At this point, the viewer is aware of the report that it must display. To actually bind that data from the data source to the report, you must call the DataBind method of the Page class to make the report viewable at runtime. The following C# snippet calls the DataBind method:
This code must go in the Page_Load event in the code-behind of the page with the viewer. After the DataBind method executes, the report binds to the data source, and loads in the browser viewer. You'll notice in the following code that the ReportSource property is set in the viewer object in the HTML of the Web Form:
Page.DataBind();
When you load a report into the Web Form viewer control, there's no printing capability. That means no Print button shows up on the toolbar for the viewer. You must use the regular File, Print menu to print the reports displayed in the browser.
<CR:CrystalReportViewer id=CrystalReportViewer1 "
ReportSource='
<%# "C:\Inetpub\wwwroot\CrystalWebTest\WebReport1.rpt" %>'>
</CR:CrystalReportViewer>
• Table of Contents
• Index
Sams Teach Yourself Visual Studio® .NET 2003 in 21 Days
By
Jason Beres
Publisher
: Sams Publishing
Pub Date
: January 14, 2003
ISBN
: 0-672-32421-0
Pages
: 696
Sams Teach Yourself Visual Studio .NET in 21 Days will help developers that are new to application development and experienced developers understand how to use the .NET Framework and Visual Studio .NET to rapidly develop any type of computer application. The Visual Studio .NET development environment is the most comprehensive developer tool ever created, putting that together with the .NET Frameworks' Class Libraries, the developer has everything he or she needs to get up-to-speed on Microsoft's latest revolution in application development. This book will guide the developer through using the VS .NET IDE, the Visual Basic .NET and C# language, and the supporting tools available from Microsoft to create Windows and Web-based applications. The market is full of books that pretty much say the same thing, which is already available in the help files, the author of this book has written and deployed over a dozen successful applications using Visual Studio .NET and the .NET Framework. All of his expertise and experience is used to give you the most comprehensive title on using Visual Studio .NET.