C#•Bind Your ADO.NET Data

Listing 3. Use a Crystal Reports CrystalReportViewer object to bind your ADO.NET data. Once you retrieve the desired information into a data set, binding it to the Crystal Reports viewer is as simple as binding it to an ASP.NET data grid.

public class PrintingWithCrystal : System.Web.UI.Page
protected SqlDataAdapter sqlDataAdapter1;
protected SqlCommand sqlSelectCommand1;
protected SqlConnection sqlConnection1;
protected CrystalDecisions.Web.CrystalReportViewer 
protected VSM102004.OrderDetailsForOrder 
protected SqlParameter ParamOrderID;
private void Page_Load(object sender, 
   System.EventArgs e)
   // Make sure an OrderID was sessioned off
   if (Session["OrderID"] != null)
      // Set stored proc filter value to select only order data for this Order ID
      ParamOrderID.Value = 
      // Set up new report based on Crystal RPT class created
      ReportDocument myReportDocument = new 
      // Get data for order and populate dataset
      CrystalReportOrders.ReportSource = 
      // Put everything on the same page and create a 
      // printable version
      CrystalReportOrders.DisplayGroupTree = false;
      CrystalReportOrders.SeparatePages = false;
      CrystalReportOrders.DisplayToolbar = false;