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

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();


  crParam.CurrentValues.Add(crDiscreteValue);


  


  CrystalDecisions.CrystalReports.Engine.ReportDocument crFFAssist = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
  crFFAssist.Load(@"C:\WebSites\FFAssistant\FFAssist2.rpt");
  foreach (CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition crParmField in crFFAssist.DataDefinition.ParameterFields)
  {
   crDefValues.Add(crDiscreteValue);
   crParmField.ApplyCurrentValues(crDefValues);


   //  crFFAssist.ParameterFields.Add(crParmField);
  }
  //crFFAssist.ParameterFields.Add(crParams);


  CrystalReportViewer1.ReportSource = crFFAssist;
  CrystalReportViewer1.DataBind();


 }

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 ASPAlliance.com  |  Page Processed at 2024-03-29 2:49:19 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search