I have explained in detail about ReportViewer and how to create report using ReportViewer in my previous article. In this article, I will show you how you can add images to your report. No matter how we create our reports but we definitely need images on it to be more attractive or we have to add images for user needs. There are more than one ways to add image in ReportViewer control and that image will be on your report. You can simply add an embedded image to your application or you can add an external image or the image may be in database and you can add it from database.
How to add an embedded image in ReportViewer control
- Right click on the Images in report menu in rdlc file.
- Click Add Image, browse and select your image and add it.
- Now click Insert > Image>select embedded and select the added image.
How to add external image in ReportViewer control
- You can add external images in two ways. First you can simple add it in rdlc file.
- Click Insert > Image > select External and add file path. “File://” is the key for connection to the local drive.
- Second, you can add external image using code
- You need to add a parameter by right clicking on Parameters in report menu in rdlc file.
- Change parameter name according to your need.
- Click Insert > Image > select External and add parameter value. “file:///” is the key for connection to the local drive.
- Now write following lines of code in your code file where you are generating your report
ReportParameter paramss = new ReportParameter;
paramss = new ReportParameter("ReportImageParam", "C:\\Images\\Tulips.jpg");