I am storing picture name only in database, actual picture gets stored in project directory 'SiteImages'.
Now I want to display the image in RDLC report but not getting displayed. CODE:
public void Fill_AuditsReport()
{
ReportViewer1.AsyncRendering = false;
ReportViewer1.SizeToReportContent = true;
ReportViewer1.ZoomMode = ZoomMode.FullPage;
this.ReportViewer1.Reset();
DataTable dt = new DataTable();
PersonalInfo.ManagePersonalInfo MngPersonalInfo = new PersonalInfo.ManagePersonalInfo();
dt = MngPersonalInfo.ReportSelectPersonalInfo();
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/DataManagementReports/Report.rdlc");
ReportDataSource rpds = new ReportDataSource("DataSetPersonalInfo", dt);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rpds);
ReportViewer1.Visible = true;
}
the name of the field in database is PersonalInfoEmployeePicture.
Add the following code to your project:
ReportViewer1.LocalReport.EnableExternalImages = true;
string FilePath = @"file:\" + Application.StartupPath + "\\" + "SiteImages\\"; //Application.StartupPath is for WinForms, you should try AppDomain.CurrentDomain.BaseDirectory for .net
ReportParameter[] param = new ReportParameter[1];
param[0] = new ReportParameter("ImgPath", FilePath);
ReportViewer1.LocalReport.SetParameters(param);
Then in the report designer, make sure the Image item has the image source property set on External
and you have a parameter with the correct name (ImgPath). Then simply define an expression that directs to the right image. (This will vary depending on how you stored the image namein the database, with our without extension, I'm assuming you added the extension)
= Parameters!ImgPath.Value + Fields!PersonalInfoEmployeePicture.Value