Pass Values to Crystal Report Formula Field

Pass values dynamically to crystal report formula field

rpt.DataDefinition.FormulaFields["Head1"].Text = "'" + Session["BRANCH_NAME"].ToString() + "'";
rpt.DataDefinition.FormulaFields["Head2"].Text = "'" + Session["ADDRESS1"].ToString() + "'";
rpt.DataDefinition.FormulaFields["Head3"].Text = "'" + head3 + "'";
rpt.DataDefinition.FormulaFields["Head4"].Text = "'" + head4 + "'";


Author: backiyaarun25 Feb 2010 Member Level: Bronze   Points : 1


i have receive the error as Reportviewer does not contain a defenition for data definition. is there any namespace i need to include ..

Author: Chan Lemo26 Jun 2010 Member Level: Bronze   Points : 2

You can find here a detailed help of , how to pass parameter to crystal reports.


Guest Author: Mohammad Ashraf Ali25 Jun 2013

First Create an instance of Report Class, then access the member variable and use that variable in your main interface.

Suppose I have a report class Called ReportView(), there I declared a member variable like

public CrystalDecisions.CrystalReports.Engine.ReportDocument rptDocument;

Now in your report showing interface, create an instance of ReportView and follow:

ReportView rptView = new ReportView();
rptView.rptDocument.DataDefinition.FormulaFields["formulaName"].Text = "'" + txt.Text + "'";

Here, txt.Text is a textbox that contain a value and formulaName is a formula created in report design.

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: