views:

731

answers:

2

On an ASP.NET page, when a user is viewing a report from the Crystal Report Viewer(CRV) they have the ability to export the report (eg to PDF). The default filename for the export is the ID of the CRV.

I would like to set the default name to be something that is based on the parameters of the report. (eg "Sales for 2008").

I know I can add a link to the page that would and then I could code up a solution where I generated the PDF in code and the stream it to the browser, but I was hoping there might be a way to do this nativity in Crystal Reports.

A: 

If you are using Visual Studio 2008 to create the report you could edit the ReportClass created to add your DefaultName property.

Brownman98
A: 
// You could pass the parameters to the web page 
// where you have theCrystalReportViewer control
protected void Page_Load(object sender, EventArgs e)
{
  string reportId = Request["rid"];
  string reportTitle = Request["rtitle"];

  ReportDocument reportDocument = HttpContext.Current.Session[reportId] as ReportDocument;
  this.CommonCrystalReportViewer.ReportSource = reportDocument;
  this.CommonCrystalReportViewer.DataBind();

  // Set the default export file name for the report.
  this.CommonCrystalReportViewer.ID = reportTitle;
}
arakkots