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

Picturebox use embeeded if bind is null

3 Answers 262 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
Karl
Top achievements
Rank 1
Karl asked on 20 Sep 2018, 10:00 AM
I have a picturebox that I am binding to a field on a data item. But if that field is null I want to display a placeholder that is embedded in the report (i.e. as if I had just set the value of the picturebox to an image directly from the explorer). Is this possible? I can't see any way to bind the picture box value to an embedded image as it sets the 'image' property of the picture box in the definition which you can't bind to.

3 Answers, 1 is accepted

Sort by
0
Silviya
Telerik team
answered on 25 Sep 2018, 06:54 AM
Hello Karl,

You can refer to this forum post on the same topic - Picturebox with IIF Condition and relative path images. Basically, you can use IIF statement to check if the field has value then the required picture would be rendered, otherwise a default picture would be rendered. For example:
this.pictureBox1.Value = "=IIf(IsNull(Fields.DataItemValue, "") = "", \"default.png\", Fields.SubsequentImage)";

This means that if the field is containing a Null value, will be replaced with default.png , otherwise it will render the value of an subsequent image.

In case of further issues, open new support ticket and send us the report definition for local testing.

Regards,
Silviya
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Karl
Top achievements
Rank 1
answered on 25 Sep 2018, 08:28 AM
Thank you for your response, but this unfortunately doesn't answer my question. Default.png in the case of your example needs to be somewhere on the drive of the machine the report is being generated on. I want the 'else' part of that statement to be the embedded picture that is in the report template itself.
0
Silviya
Telerik team
answered on 27 Sep 2018, 02:34 PM
Hi Karl,

I'm sorry for misunderstanding you exact requirement for the default *embedded* image.
In this case this cannot be directly achievable though bindings, because after evaluation of the expression, the Value of the PictureBox will be updated.

Instead, I can recommend two other approaches:
1. Set embedded background image to the PictureBox item as default and binding like:
=IIf(IsNull(Fields.image, "") = "", null, Fields.image)

 in order to achieve the desired behavior.
2. Use an user function to retrieve the required image with the needed environment setup.

Regards,
Silviya
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Report Designer (standalone)
Asked by
Karl
Top achievements
Rank 1
Answers by
Silviya
Telerik team
Karl
Top achievements
Rank 1
Share this question
or