locked
Image from rs folder - hide the red cross when image is not present RRS feed

  • Question

  • I have images stored in the reporting service folders.

    In the report I put an image with image source as ="..\Images\" & Parameters!myparameter.Value where myparameter is the image name. By design, sometimes the image of that name is present and other times it is not. When it is not, the report displays a red cross icon in place of the image.

    How can I fix this so if there is no image present then there will be just white space?


    James.


    • Edited by JamesCass Wednesday, November 22, 2017 12:51 PM
    Wednesday, November 22, 2017 12:50 PM

All replies

  • Hi,

    Add a function in your report to check if a file exists, something like this :

    Public Function FileIsExists(ByVal filePath As String) As Boolean Return System.IO.File.Exists(filePath) End Function

    And then use this expression to check if the image exists or not, if not insert a default image (The default image has to be in the folder) :

    =iif (Code.FileIsExists("..\images\" + cstr(Parameters!myparameter.value)),
    "..\images\" + cstr(Parameters!myparameter.value),"..\images\yourDefaultimage.png")


    Please mark as answered, If you feel happy with this answer.

    Wednesday, November 22, 2017 1:04 PM
  • A simple if is nothing your param value then nothing else param Should do Do the same to the hidden property of the image

    gkd



    • Edited by gkd Wednesday, November 22, 2017 1:22 PM
    Wednesday, November 22, 2017 1:18 PM
  • You can handle this by adding a flag field in your database table.

    Just populate field with 0/1 depending on image availability

    In the report have an expression to check for this like

     =IIF(Fields!FlagColumn.Value = 1,"..\Images\" & Parameters!myparameter.Value,Nothing)


    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    ----------------------------
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

    • Proposed as answer by Henry Jiang Friday, December 1, 2017 1:37 AM
    • Unproposed as answer by JamesCass Friday, December 1, 2017 6:45 AM
    Wednesday, November 22, 2017 1:23 PM
  • This would work but it is specifically what we do not want to do because it involves modifying the db schema and updating two places every time an image is inserted, once the file and once the bit field.

    James.

    Wednesday, November 22, 2017 8:46 PM
  • =Iif(IsNothing("..\Images\" & Parameters!MyParameter.Value),"True", "False")

    This always evaluates to False regardless if the image is present to not.

    The parameter is always present. It is just a question if that file name is found or not.


    James.

    Wednesday, November 22, 2017 8:50 PM
  • I think this might work if the file is a physical file on disk. But in my case the file is in the reportserver itself, so system.io does not apply.

    James.

    Wednesday, November 22, 2017 9:00 PM
  • Hi,

    What about controlling the image visibility based on the parameter values, if the values equal to specific ones then show the image else hide it. 

    Regards

    Monday, November 27, 2017 2:08 AM
  • Parameters could be used but how can we set them? How can we set a parameter value to detect if an image is present or not.

    The objective is that if there are hundreds of products and only some have pictures, then we can just drop the pictures to the report server and not have to update databases to tell that there is an image present or not. It will become quite difficult to 100% synchronise that every image has a bit field true or not.


    James.

    Monday, November 27, 2017 11:57 AM
  • It may be not feasible to use parameters if you have hundreds of products. To manually insert the pictures in the report you want might be an alternative.

    Regards

      
    Tuesday, November 28, 2017 9:01 AM