I have a report with two webservice data sources - webServiceDataSource1 and webServiceDataSource2. In the Report Designer, how do I get a picturebox control to get the base64 string (which may be null) from the webServiceDataSource2.imageBase64 field?
1 Answer, 1 is accepted
0
Dimitar
Telerik team
answered on 10 Apr 2023, 07:24 AM
Hello Neil,
If I understand correctly, the PictureBox in question is used within a data item whose DataSource is webServiceDataSource1 and you are wondering how to use the data of the second WebServiceDataSource, is that correct?
There are basically two approaches that I would recommend choosing from:
(Not Recommended)Nest a second data item, inside the original one, and put the PictureBox in the nested item. The nested item should have its DataSource set to webServiceDataSource2, this way you will be able to use the base64 string field but be aware that this might result in the PictureBox being rendered more than once due to the nature of data items.
Please test the two approaches and if you have any additional questions, or if you need further assistance, please send me the report alongside some sample data that I could use to prepare a solution locally.
Thank you for using Telerik Reporting!
Regards,
Dimitar
Progress Telerik
Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you
up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
I'm now passing the base64 string as a report parameter and assigning =Parameters.photoBase64.Value as the picturebox value works. But how do I avoid having the picturebox showing an error if "" (i.e., no picture) is passed?
Dimitar
Telerik team
commented on 13 Apr 2023, 09:34 AM
You can condition to the Value expression used by the PIctureBox. For example, you may check if the value of the report parameter is null or an empty string and you may return some default image:
= Parameters.Parameter1.Value Is Null Or Parameters.Parameter1.Value = "" ? default_image : Parameters.Parameter1.Value
The above expression could also be implemented with the If(Condition, ReturnedIfTrue, ReturnedIfFalse)conditional function. If you do not need to display a default image, you can instead use the expression to bind the Visible property of the PictureBox item.
If you need to use more complicated logic, you may instead create a custom function that takes the value of your parameter and return a default image when there is no picture in the report parameter value - Custom User Functions Explained - Telerik Reporting.