none
How to send a picture to a report(rdlc) in a reportviewer? RRS feed

  • Question

  • Hello everyone,

    I've troubles with sending a picture/image to my report.rdlc.
    My report works great with the rest.
    The code to send the data is what i have is example.:

     parameters(0) = New Microsoft.Reporting.WinForms.ReportParameter("ParameterName", Form1.rptlbl0.ToString)
    But how do i send a image what is saved to a report, this image changes every time whats saved.
    Can anybody help, ps sorry for my bad english i'm from holland.
    Tuesday, June 16, 2009 3:46 PM

All replies

  • Parameters can only be text, you can't send binary data as a parameter. You have two primary options:


    -- Have your images stored externally, perhaps on a web server or on a local filesystem. Then pass in as a parameter which image you want to use, and set that as the value for an Image ReportItem in your report. The Image ReportItem will need to have its Source set to "External" and your ReportViewer's report object will need to have EnableExternalImages set to true.

    -- Embed all the images you want to use into the report itself. When the report is focused in VS, go to the Report menu, then select "Embedded Images..." In this dialog, embed all the images you need, and give them all names. Then much like above, set an Image ReportItem's value to the name of the image. Since the images are actually embedded in the report, your report will become larger.



    This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, June 16, 2009 8:18 PM
  • I disagree with Matt, you cand send an image as parameter converting it to Base64, looks like this:


    Dim Base64 As String = ConvertImageToBase64(yourimg, System.Drawing.Imaging.ImageFormat.Jpeg) 'And then in the parameters RP.ParamList.Add(New ReportParameter("ReportLogo", Base64, True)) RP.ParamList.Add(New ReportParameter("ReportLogoMimeType", "image/jpg", True))

    In your rdlc file:

    >Add 2 parameters:
    ReportLogoMimeType
    ReportLogo

    >add an image and set the following properties to the image:

    MIMEType: =Parameters!ReportLogoMimeType.Value
    Source: Database
    Value: =System.Convert.FromBase64String(Parameters!ReportLogo.Value)


    G.Waters




    Wednesday, May 29, 2013 6:29 AM
  • To G.waters instead of passing the MIME type we can set it in the wizard itself. Anyways your solution was of great help Sir.
    Sunday, March 8, 2015 1:27 PM