I have an asp.net web application that I am having a problem loading images into rdlc reports. I have scoured the internet and have tried a lot of the suggestions and still am stuck. I would appreciate some assistance. I am using VS 2013 Ultimate.
In my project there is a folder called Photos which currently contain about 4,000 images. These photos are not in the database. When I create my report using the report wizard, I use view in sql server 2016 to pull applicable records, let's just say I pull Name, and Photo. The names would be strings, "Wanda", "Mike" and the photos are the relative path to the project: "~/Photos/Wanda.jpg" and "~/Photos/Mike.png". NOTE, some aer jpg, some jpeg, and some png files. So when my report displays I have a field for Fields!Name.Value and one for Fields!Photos.Value. Names display but not the photos, just their text path. I then inserted an Image tool from the toolbox into a Text box on the report, and marked it as External in type, and set the value of the image to Fields!Photos.Value. The code behind the report located in the webpage holding the report viewer looks like this:
ReportViewer1.LocalReport.EnableExternalImages = true;
ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", ObjectDataSource2));
ReportViewer1.LocalReport.ReportPath = "Report1.rdlc";
ReportViewer1.LocalReport.ReportEmbeddedResource = "Report1.rdlc";
ReportViewer1.LocalReport.Refresh();
ReportViewer1.Focus();
When the report is run, all the selected names appear but not the pictures. I ran across a nice example by this gentleman:
https://www.aspsnippets.com/Articles/Dynamically-add-and-display-external-Image-in-RDLC-Report-from-code-behind-in-ASPNet.aspx
Which seems to be the best one so far, but I do not wish to copy all my photos again to the Report1.rdlc report data images file. I want to keep them where they are. What must I do to load and display the images and to ensure the Mime type of each is set correctly for the display?
If this is not the correct forum please be kind enough to direct me to the correct one.
Thanks in advance.
Noel