none
Image Value Expression Expected? RRS feed

  • Question

  • I am creating a report in Visual Studio 2010 using the report designer, and am trying to set an image by using an expression.

     

    Here is my code: 

    = Iif(Fields!pic1.Value.ToString() == null,null,"file://"&Fields!pic1.Value)

    I get no expression errors when pressing ok, but when i go to build i get an error:

    Error 3 The Value expression for the image ‘image2’ contains an error: [BC30201] Expression expected.

    Is there anything wrong with the code, or could it be because VS2010 converted it from 2008 to 2010?

    Thursday, June 3, 2010 8:24 PM

Answers

  • <

     

     

    Value>=IIf(Fields!pic1.Value Is Nothing, "", "file:///" &amp; Fields!pic1.Value)</Value>

     

    Use "&amp;" to edit the report in source mode, because the caracter "&" is invalid in the XML document

    ;)


    Lucas
    • Marked as answer by DanielHobbs Saturday, June 12, 2010 5:16 PM
    Friday, June 4, 2010 6:35 PM

All replies

  • Hi,

    try this:

    =IIf(Fields!pic1.Value

     

    Is Nothing, "", "file:///" & Fields!pic1.Value)


    Lucas
    Friday, June 4, 2010 2:36 PM
  • Thanks for the reply. I think we're getting somewhere now.

     

    I have put this line in - 

    <Value>=IIf(Fields!pic1.Value Is Nothing,"" , "file:///" & Fields!pic1.Value)</Value>

    But am getting a different error on that line. I have changed it back to a 2008 version running inside the 2010 app, i dont know if this will cause this error.

     

    Error 2 The report definition is not valid.  Details: An error occurred while parsing EntityName. Line 153, position 67.


    Friday, June 4, 2010 5:12 PM
  • <

     

     

    Value>=IIf(Fields!pic1.Value Is Nothing, "", "file:///" &amp; Fields!pic1.Value)</Value>

     

    Use "&amp;" to edit the report in source mode, because the caracter "&" is invalid in the XML document

    ;)


    Lucas
    • Marked as answer by DanielHobbs Saturday, June 12, 2010 5:16 PM
    Friday, June 4, 2010 6:35 PM
  • Now i get this error:

     

    Error 4 The Value expression for the image ‘image3’ contains an error: [BC30451] 'Iof' is not declared. It may be inaccessible due to its protection level.

    Friday, June 4, 2010 7:38 PM
  • You didn't write Iof(...) accidentally instead of IIf(...)?

    I advise you to edit expressions of the Report Viewer by the wizard window, not directly to the source.


    Lucas
    Friday, June 4, 2010 9:35 PM
  • How did manage to type Iof? Hmmmm.. Fixed it by changing it to Iif.

    Is there anyway that i can set a picturebox to be blank, instead of displaying the error placeholder (little white square with X)?

    Saturday, June 5, 2010 2:27 PM
  • Hi,

    yeah! In Image Properties > Visibility: chosing "Show or hide based on an expression" and type this:

    =IIf(Parameters!your_param_logo.Value Is Nothing, False, True)


    Lucas
    Tuesday, June 8, 2010 12:02 AM
  • Ive popped this code into the XML behind the report: <Visibility> <Hidden>=IIf(Fields!pic1.Value Is Nothing, False, True)</Hidden> </Visibility> and it just constantly hides it. If i switch the False and True around, it shows all the time. It is doing where there is no image correctly, but if there is an image, it hides it anyway.
    Tuesday, June 8, 2010 9:06 PM
  • If Fields!pic1.Value contains string value replace [Fields!pic1.Value Is Nothing] by [Fields!pic1.Value.ToString = ""] and try again. Because both "" and "completePath" is not Nothing.

    I think it will work :D


    Lucas
    • Marked as answer by DanielHobbs Saturday, June 12, 2010 5:16 PM
    • Unmarked as answer by DanielHobbs Saturday, June 12, 2010 5:16 PM
    Wednesday, June 9, 2010 5:26 PM
  • Wahey, thank you very much for your help.
    Saturday, June 12, 2010 5:16 PM
  • Hi, devlucas

    I saw you help the questioner to solve image.value using experssion issue here. I have a similar issue here.

     

      I have created a local report , generating the RDL at runtime in VS2005. I have several embedded images within my RDL, all images display fine as long has I set the containing image control value to the desired embedded image name.

    But once I set the image.value to experssion, it doesn't work anymore.

    I put image source as "embedded" and the value has experssion: =Switch(Fields!isOwnerSign.Value = 1, "davidji", Fields!isOwnerSign.Value = 0, "whitesignature")

    davidji is embedded image name. I found I have to put double quote around the image name to let VS2005 compile success.

    Do you have idea why once I use the experssion, the image not show anymore?

     

    I found this link which has the same issue as mine but I didn't understand how he/she solve the problem

     

    http://social.msdn.microsoft.com/Forums/en/vsreportcontrols/thread/677294f9-892a-4636-a962-ff9f8979a63d

     

    Friday, December 17, 2010 1:10 AM