Sample App: FFAssist Using Crystal .NET for VS 2005 - Part 2
page 3 of 5
by Eric Landes
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 23228/ 47

Displaying the Report on a Web Page

[download sample app]

Now that we've designed the report we want to display this on a web page.  Displaying the report is similar to the way we did this in .NET.  However I find binding to the viewer programmatically to be easier in this version.  

In this application, the report displays when a Player is selected.  In this case the drop-down list is named DropDownList1.  The code below is what fires when SelectedIndexChanged fires.

void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  CrystalDecisions.Shared.ParameterDiscreteValue crDiscreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue();
  crDiscreteValue.Value = ddlPlayers.SelectedValue;
  CrystalDecisions.Shared.ParameterField crParam = new CrystalDecisions.Shared.ParameterField();
  CrystalDecisions.Shared.ParameterFields crParams = new CrystalDecisions.Shared.ParameterFields();
  CrystalDecisions.Shared.ParameterValues crDefValues = new CrystalDecisions.Shared.ParameterValues();



  CrystalDecisions.CrystalReports.Engine.ReportDocument crFFAssist = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
  foreach (CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition crParmField in crFFAssist.DataDefinition.ParameterFields)

   //  crFFAssist.ParameterFields.Add(crParmField);

  CrystalReportViewer1.ReportSource = crFFAssist;


First a ParameterDiscreteValue is declared, then a ParameterField, then the collections, ParameterFields, and ParamaterValues.  After loading the file, iterate through the parameter field definition collection in the document.  One way to make the iteration work is to name the obects in your page with the same name as the parameter.  Then you can access that control with that parameter name.  I don't do that here, but that's something I will pursue as I add to this sample application.

Finally, bind the report document crFFAssist to the report viewer.  You still set the report source then bind the data.

View Entire Article

User Comments

No comments posted yet.

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024  |  Page Processed at 2024-02-22 4:56:25 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search