Wednesday, December 7, 2011

How to Display Dynamic Images in Crystal Report


How to use Dynamic images in Crystal Report with out Using Database



Step 1: Add Pictures in Crystal report and Suppress all the pictures

For example:
let us Consider 5 pictures A,B,C,D,E. Add those Pictures using Insert Picture Proberty After Adding just supress the all 5 Pictures.

Step 2:
In Your Asp.net Page Just check the the condition according to that remove Suppress option



Code:

using crystalDecisions.Shared;
using crystalDecisions.crystalReports.Engine;

ReportDocument crDoc=new ReportDocument();
crDoc.load(crystalreportpath,OpenReportMethod.OpenReportByTempCopy);
if(id=="A")
{
 crDoc.ReportDefinition.Sections("SectionNameinCrystalReport")
.ReportOject("PicturelabelName").ObjectFormat.EnableSuppress=False
}
else if(id=="B")
{
 crDoc.ReportDefinition.Sections("SectionNameinCrystalReport")
.ReportOject("PicturelabelName").ObjectFormat.EnableSuppress=False
}
else if(id=="C")
{
 crDoc.ReportDefinition.Sections("SectionNameinCrystalReport")
.ReportOject("PicturelabelName").ObjectFormat.EnableSuppress=False
}
else if(id=="D")
{
 crDoc.ReportDefinition.Sections("SectionNameinCrystalReport")
.ReportOject("PicturelabelName").ObjectFormat.EnableSuppress=False
}
else if(id=="E")
{
 crDoc.ReportDefinition.Sections("SectionNameinCrystalReport")
.ReportOject("PicturelabelName").ObjectFormat.EnableSuppress=False
}