In the downloadable project, the default.aspx file has a CrystalViewer object on it. To accomplish this, I just dragged and dropped the Crystal Report Viewer onto the default.aspx page (in design mode).
In code, binding the viewer to a report with a DataSet populated in the code-behind is similar to the methods used in VS 2003. But, utilizing the auto-created object makes this a little easier. First, create the object, and populate all the different tables. Then, create a Report object and bind it to the Business Object filled with all the data.
Listing 4: Bind the report to the viewer
CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt =
FFAssistantDataSet oDataSet = new FFAssistantDataSet();
PlayersTableAdapter oPlayers = new PlayersTableAdapter();
String strConn =
oPlayers.MainConnection = strConn;
TeamsTableAdapter oTeams = new TeamsTableAdapter();
oTeams.MainConnection = strConn;
StatsTableAdapter oStats = new StatsTableAdapter();
oStats.MainConnection = strConn;
PositionsTableAdapter oPositions = new PositionsTableAdapter();
oPositions.MainConnection = strConn;
CrystalReportViewer1.ReportSource = oRpt;
As you see in Listing 4, I set the connection string to the connection stored in the web.config file. This should look familiar if you are already binding data to your report using Visual Studio 2003. Just create a new ReportDocument object, and then load the report into that object. After filling the DataSet object with data, we bind it to the ReportDocument. Finally, the ReportDocument object is set as the ReportSource for the viewer. Build and run the web application and you'll see the report!