Open the crystal report you have just created in your project, and from the Field Explorer -> Formula Fields, right click and create Two new Formula Field Variables, lets name it as "parameter1" and "parameter2" respectively. Then drag and drop inside the Crystal Report and place it anywhere according to your need.
Then, use the below code (assume if we need to pass "Hello" & "How are you?" during runtime)
ReportDocument ReportDoc = new ReportDocument();
ReportDoc.Load(Server.MapPath("~") + "\\CrystalReport1.rpt");
ReportDoc.Load(Server.MapPath("~") + "\\CrystalReport1.rpt");
List paramList = List();
paramList.Add("Hello");
paramList.Add("How are you?");
for (int i = 1; i < 2; i++)
if (ReportDoc.DataDefinition.FormulaFields[i-1].FormulaName
== "{" + "@parameter" + i + "}")
ReportDoc.DataDefinition.FormulaFields[i-1].Text
= "\"" + paramList[i-1] + "\"";
== "{" + "@parameter" + i + "}")
ReportDoc.DataDefinition.FormulaFields[i-1].Text
= "\"" + paramList[i-1] + "\"";
0 comments:
Post a Comment