Sunday, February 5, 2012

How to pass parameter value to crystal report

Dynamic Value to report:


1. First Learn to Create a simple crystal report
http://aspnetguru.blogspot.in/2011/04/dynamic-crystal-reports-in-c-asp-net.html


2.From window Field Explorer>Parameter Field> (Rightclick) New>Write parameter name and selects its value type then OK.


3.Go to same window of Field Explorer>Parameter Field >(expand it) and drag your parameter to report.


4.use following C# code where you are writing code for cristalreportviewer:






MyCrystalReport report = new MyCrystalReport();





 report.SetParameterValue("Department", "Accounting");
               
CrystalReportViewer1.ReportSource = report;




Note: You can use setparameter value in if condition also.
Use complete code for report this is incomplete code only to show how to pass parameter.
Department is the parameter name i have created in my report.
Accounting is the value for the department parameter.


Give comment for any query based on crystal reports..



No comments:

Post a Comment