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 + "'";


Comments

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

Hi...


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.

http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-string-parameter.htm

http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-integer-parameter.htm

http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-date-parameter.htm

Tks-chan

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.