To Pass TextBox Value to Crystal Report without using Database

To pass TextBox value to crystal report without using database :

  1. First create a parameter in the paraeterField in the DatabaseFileds, name it crParam.
  2. ReportDocument cryRpt = new ReportDocument();
     cryRpt.Load(@"C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\CrystalReportsWithParam\CrystalReportsWithParam\CrystalReportsWithParam\CrystalReport1.rpt");     
     

    ParameterFieldDefinitions crParameterFieldDefinitions ;

    ParameterFieldDefinition crParameterFieldDefinition ;

    ParameterValues crParameterValues = new ParameterValues();

    ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();

    crParameterDiscreteValue.Value = textBox1.Text;

    crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields ;

    crParameterFieldDefinition = crParameterFieldDefinitions["crParam"];

    crParameterValues = crParameterFieldDefinition.CurrentValues;

    crParameterValues.Add(crParameterDiscreteValue);

    crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

    crystalReportViewer1.ReportSource = cryRpt;

    crystalReportViewer1.Refresh();  

  Now drag and drop that parameter crParam on crystalReport where ever you want to display in that's it.

Ebook Download
View all
Learn
View all