[Solved] Display External image in RDLC Report in ASP.Net

Last Reply on Sep 12, 2015 02:43 AM By Abumaizer

Posted on Sep 11, 2015 02:55 AM

Hi,

I upload images to server and store their path in a table (varchar(MAX)). 

I managed to create a report and show the records from that table but I could not bind the image to its datasource (stored path).

My path looks like this:

~/ARTSQLDATA/PTDIR/15090248/IDFTO/15090248PPID.jpg

Please help!

Thanks

Posted on Sep 12, 2015 02:43 AM

I programmed a solution and your feedback is highly appreciated,

I found a solution that I want to share with you and I would love to hear your feedback,

  1. I modified my uploader function to save the image path in URI format(Encoded) (ie. Dim ImgURI As String = New Uri(Server.MapPath("URL String")).AbsoluteUri)
  2. To show the image on webform I decode the URI to URL 
  3. Function ConvertURI(URI As String)
        Dim DecodeURI As String = HttpUtility.UrlDecode(URI) 'Decode URI string
        Dim SubURI = DecodeURI.Substring(DecodeURI.IndexOf("Your Folder"))
        Dim URL As String = "~/" & SubURI ' Restore the URL string format
        Return URL
    End Function
        
    ' then in your code
    Dim ImgURL As String = ConvertURI("Your URI")
    Sampleimg.ImageUrl = ImgURL
  4. To show the image in your RDLC report just set the image control source to external and assign the image value to field value in your table

Your feedback is highly appreciated, Thanks!