Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

I am working on a win form application which uses RDLC report. I would like to show images from external sources I used Report Parameter and assigned the value of external sources to that parameter but while generating it keeps hanging.

Here is a piece of code:

C#
reportViewer1.ProcessingMode = ProcessingMode.Local;
reportViewer1.LocalReport.EnableExternalImages = true;
reportViewer1.ShowParameterPrompts = false;
reportViewer1.ShowPromptAreaButton = false;
ReportParameter rp = new ReportParameter("ImagePath", "/Image/a.jpg");
reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });


I don't know what is wrong with the code and why it hangs? any idea please?
Posted

Hi abdul,
try this

C#
path = "file:" + System.Configuration.ConfigurationManager.AppSettings  ["PranayLogo"] + "\\logo.jpg";
reportViewer1.LocalReport.EnableExternalImages = true;
ReportParameter[] RptParameters = new ReportParameter[1];
RptParameters[0] = new ReportParameter("ImgPath", path);
reportViewer1.LocalReport.SetParameters(RptParameters);
this.reportViewer1.Update();
this.reportViewer1.RefreshReport();
 
Share this answer
 
v2
Comments
Abdul Rahman Hamidy 27-Feb-13 1:23am    
Thanks for reply, what are you storing in PranayLogo? I can simply use file:\\C:\\Image\a.jpg
instead. I found that if i even didn't pass the parameter it sill hangs? while it should tel me you didn't pass param. this is how i passed param value in report design (Value=Parameters!ImagePath.Value)
Bojjaiah 27-Feb-13 1:30am    
PranayLogo=this is the FixedPath storing in app.config like(C:\Image).

in design parameter must match the ReportParameter. Ok
i.e., design parameter(this is design param)="ImgPath"(this is code behind) must be match.
Abdul Rahman Hamidy 27-Feb-13 1:36am    
I already edited ImgPath to ImagePath. It only hangs with Image, I changed the param and i wanted to show text in a textbox it works, it only hangs with image.
Bojjaiah 27-Feb-13 1:42am    
what is ther Design parameter?
post the parameter
Abdul Rahman Hamidy 27-Feb-13 1:55am    
Thanks for the repoy. I solved it, I designed the same application in VS 2005 .Net 2.0 it worked perfect.

Before I designed that in VS 2008 .Net 3.5. I don't know why it doesn't work with .Net 3.5
Here is the complete solution:

C#
this.reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
this.reportViewer1.ZoomPercent = 100;
this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.FullPage;

reportViewer1.LocalReport.EnableExternalImages = true;
ReportParameter[] RptParameters = new ReportParameter[1];
RptParameters[0] = new ReportParameter("Path", "file:///" + "c:\\GOVT.jpg");
reportViewer1.LocalReport.SetParameters(RptParameters);

reportViewer1.LocalReport.Refresh();


I just changed it to look like below

C#
reportViewer1.LocalReport.EnableExternalImages = true;
ReportParameter[] RptParameters = new ReportParameter[1];
RptParameters[0] = new ReportParameter("Path", "file:///" + "c:\\GOVT.jpg");
reportViewer1.LocalReport.SetParameters(RptParameters);

reportViewer1.LocalReport.Refresh();

this.reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
this.reportViewer1.ZoomPercent = 100;
this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.FullPage;


Now it works perfect!!!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900