This is a migrated thread and some comments may be shown as answers.

Hide PictureBox Issue

1 Answer 763 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sanjaya Kodagoda
Top achievements
Rank 1
Sanjaya Kodagoda asked on 11 Oct 2014, 06:52 AM
Hi Guys,

I'm new to reporting and there is a requirement to display an image in my report and I'm using a picture box for this. 

Problem I have is I want to display this image only when it is available. From my dataset I'm returning the image path(this will always return a path if image is present or not) and a boolean value indicating if the image is present. 

So I tried adding an conditional formatting rule to picture box defining layout should not be visible when the Field.ImageAvailable property is false. But when I render the report, it displays image not found error.

So have I missed anything or is there any other way to handle this?

Thanks in advance!!

1 Answer, 1 is accepted

Sort by
0
Hinata
Top achievements
Rank 1
answered on 15 Oct 2014, 02:33 PM
Hi Sanjaya,

All invisible/hidden report items will also be processed by the reporting engine.
This means the picturebox will generate a visible error when you pass an invalid image path to it, even though it is set to be invisible.

To handle this better, in addition to the conditional formatting you should pass the value path in the expression conditionally. Something like the following expression:

PictureBox.Value = "= IIf(Fields.ImageAvailable = True, Fields.ImagePath, Null)"
pini
Top achievements
Rank 1
commented on 08 Dec 2021, 01:06 PM

Hi, I also have the same problem  (Errors on the report "Could not find a part of the path" )- 

But this solution  :

PictureBox.Value = "= IIf(Fields.ImageAvailable = True, Fields.ImagePath, Null)"

not works. 

Can you please recheck your answer Or detail the answer maybe I did not understand it as should?

Thanks in advance 

 

Todor
Telerik team
commented on 13 Dec 2021, 10:00 AM

Note that the above Expression will set the Image of the PictureBox item to Null when not available, so the PictureBox will be displayed empty rather than with an error message. You need to check also the type of the field "ImageAvailable". For example, with a field of Boolean type, you may use an Expression like:

= IIF(Fields.ImageAvailable, Fields.ImagePath, Null)

If it is a string, assure the correct case-sensitive value for the "True" state.

If you would like also to hide the PictureBox item, you need to use Bindings or Conditional Formatting with a similar Expression. The conditional statement for the Value of the PictureBox should remain, as it needs to be evaluated to a valid image, otherwise will display a processing error.

I have attached a sample report demonstrating the above.

Tags
General Discussions
Asked by
Sanjaya Kodagoda
Top achievements
Rank 1
Answers by
Hinata
Top achievements
Rank 1
Share this question
or