[ACCEPTED]-Setting image source in RDLC report dynamically-reporting

Accepted answer
Score: 29

As there are no alternate (or any!) opinions 29 on the matter, I've moved further along 28 and have come up with a working solution.

I'm 27 opting to create an on-demand file of the 26 logo, storing it in a temp location. If 25 the file doesn't exist, I'm creating it 24 on the fly. If it does exist, I'm just 23 referencing the image that does exist.

In 22 the RDLC report, I've created a parameter 21 called Path of type Text. Next, in the 20 properties for the Image, I've changed the 19 logo image from embedded to external and 18 set "Use this image" to be the 17 parameter: [@Path].

Then, in the code I'm 16 passing in the file path as the Path parameter. But 15 where I had previously gone wrong is that 14 the path has to be a URL and I had been 13 attempting to pass the location on disk. So, that 12 portion should look like this:

        ReportParameter paramLogo = new ReportParameter();
        paramLogo.Name = "Path";

I will say 11 that the MSDN documentation could be a little 10 better. To their credit, there are many 9 detailed documents about how to accomplish 8 something at a higher level. This article helped. It 7 clearly says that I needed a URL to the 6 path, but it'd have been easier to examine 5 that property directly in the library. However, finding 4 the lower level documentation was harder 3 and less fruitful. Here is the article for the 2 Reporting Image object. There isn't much 1 opportunity to set properties of interest.

Score: 13

I was having the same problem, however the 4 accepted solution didn't quite work for 3 me. Turns out that I needed to set EnableExternalImages to true 2 in addition to providing the path in URI 1 format and setting my Image.Value to =Parameters!ReportLogo.Value.

report.EnableExternalImages = true;
ReportParameter[]  parameters = new ReportParameter[3];
Uri pathAsUri =  new Uri(_info.LogoPath);
parameters[2] = new ReportParameter("ReportLogo", pathAsUri.AbsoluteUri);

More Related questions