There are 3 ways in which you can add images to your report
1. Embeded
2. External
3. Database
Embeding Images
Open your report. Drag and drop an image icon.
Click on the image and press F4, the properties window pops up
Under the group data you'll find source choose embeded.
To embed images to your report choose report property on the menu (Click on the report if you can't see this),
Click on Report Images and choose the images you want to embed.
Now, In the value property of your image choose the image you want to display.
Embedded images are ok for small logo files, but for huge bmp files external images work better.
External Images
Set the source as external and set the value for external files as the virtual path to the image folder. ex: http://servername/imagefoldername/imagename
Also enable external images in your aspx page
ReportViewer1.LocalReport.EnableExternalImages = True
Database Images
Set the source as Database and set the value for external files as the fieldname
In the textbox write the foll expression.
=Convert.ToBase64String(Fields!Image.Value)
Placing a database image in your header
Since database fields are not accessible from the header, place a hidden textbox in your report call it tb_images and set the value, as mentioned above for database images. Now place an image icon in the header and set its value to the hidden image textbox i.e
=ReportItems!tb_Image.Value
Dynamically Change Image
In certain case you may have to dynamicaaly place a header image based on the department.
The code can be placed in a code window. Select Report -> Report Properties -> Code (tab) in the VS.NET designer.
Function ShowHeaderImage(value as Object) As String
Dim strURL as String = "http://
Dim strImg as String
Select Case value
Case Nothing
strImg = "heading1.jpg"
Case 1
strImg = "heading2.jpg"
Case 2
strImg = "heading3.jpg"
End Select
Return strImg
End Function
Place an image icon in the report body and set its source as external. In the value property
enter the following
=Code.ShowHeaderImage(Fields!
2 comments:
How do you have a custom image in the page header? I tried ReportItem!image1.value but it does not work. Thsi method works for text boxes though
You can place database/external images in your header/footer by passing the value as a parameter to your report. Call this parameter in the "value" property of your image.
=parameters!headerimage.value
where headerimage is the name of your parameter
Post a Comment