9

I am trying to add an external photo as the logo along with the report on the report.rdlc file. I have this error

The enable externalimages property has not been set for this report

enter image description here?

Here is my code.

 try
{
    this.pedidosTableAdapter.Connection.ConnectionString = con.MysqlConnect();

    this.pedidosTableAdapter.Fill(this.fabricacaoDataSet8.pedidos, Pages.relatorios.num);
    this.reportViewer1.RefreshReport();
}
catch { }

// for external image
this.reportViewer1.LocalReport.EnableExternalImages = true;
ReportParameter parm = new ReportParameter();
parm=(new ReportParameter("path", @"C:\logo.jpg",true));
this.reportViewer1.LocalReport.SetParameters(parm);
this.reportViewer1.Refresh();
Ryan Gates
  • 4,501
  • 6
  • 50
  • 90
Saqi
  • 151
  • 2
  • 5
  • 12
  • The code you posted swallows any exceptions without any notification, which could be part of the issue. – Ryan Gates Jun 19 '13 at 19:36
  • possible duplicate of [External images in .rdlc data reports for winforms](http://stackoverflow.com/questions/2070408/external-images-in-rdlc-data-reports-for-winforms) – Johann Blais Mar 04 '14 at 07:01

6 Answers6

7

I have experience when you enable external images using Code, it works on local / development environment but while deployment on server it does not works and reports raise error:

"The enable external images property has not been set for this report"

In order to solve this issue, use EnableExternalImages="true" property in ASPX or design file where you are using ReportViewer Control and it will work perfectly.

UMAR-MOBITSOLUTIONS
  • 77,236
  • 95
  • 209
  • 278
6

The problem here actually is, that you're calling this.reportViewer1.RefreshReport(); before setting this.reportViewer1.LocalReport.EnableExternalImages = true;.

The order is important here.

jansokoly
  • 1,994
  • 2
  • 18
  • 25
2

I hope this image is a help in your Windows Application.Activate your Reportviewer->Properties->LocalReport->EnableExternalImage and set it to Trueenter image description here

1

As mentioned here, the path of the image must be in URL format, i.e. @"file:///C:\logo.jpg"

Or you can try

var filepath = new Uri("C:\logo.jpg");
var path = new ReportParameter("Path", filepath.AbsolutePath);
this.reportViewer1.LocalReport.SetParameters(new ReportParameter {Path = path});
Community
  • 1
  • 1
Iain Ballard
  • 4,433
  • 34
  • 39
1

Nothing worked for me, But simply this worked

        LocalReport localReport = new LocalReport();
        localReport.ReportPath = HostingEnvironment.MapPath("~/Reports/myreport.rdlc");
        localReport.EnableExternalImages = true;
        localReport.EnableHyperlinks = true;
Adel Mourad
  • 1,351
  • 16
  • 13
0

For WinForm Applications, below code will works well.

string templateImage = Application_Path + @"\Images\ReportLogo.jpg";
rvRptContainer.LocalReport.EnableExternalImages = true;
rvRptContainer.LocalReport.SetParameters(new ReportParameter("ReportLogo", "File:\\" + templateImage));

For ASP.Net Applications, Do the following:

ReportViewer1.LocalReport.EnableExternalImages = true;

    string imagePath = new Uri(Server.MapPath("~/images/Mudassar.jpg")).AbsoluteUri;

    ReportParameter parameter = new ReportParameter("ImagePath", imagePath);

    ReportViewer1.LocalReport.SetParameters(parameter);

    ReportViewer1.LocalReport.Refresh();
TAB
  • 1,944
  • 8
  • 28
  • 45