Symptom
How to filter the data of a Crystal report at runtime using a selection formula with the Crystal Reports .NET SDK.
Environment
- Visual Studio 2005
- Crystal Reports 2008
Resolution
Here's a sample code that uses a selection formula to filter the data that is passed to a Crystal report using the Report Document Object Model.
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
public partial class _Default : System.Web.UI.Page
{
ReportDocument rd = new ReportDocument();
protected void Page_Load(object sender, EventArgs e)
{
rd.Load(Server.MapPath("passformula.rpt"));
string selectionFormula = "{Employee.Employee ID}> 3";
rd.DataDefinition.RecordSelectionFormula = selectionFormula;
CrystalReportViewer1.ReportSource = rd;
}
}
Keywords
cr.net. , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To
Product
Crystal Reports 2008 V1 ; SAP Crystal Reports XI R2