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

Set Image Dinamically

4 Answers 444 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Gustavo
Top achievements
Rank 1
Gustavo asked on 28 Nov 2016, 05:15 AM

Hi guys,

I have a table, and one of the columns is it works perfectly when I set the picture value from the data source.

But we have some invalid images, and we want to validate the image in the . So how can I set the image in the or maybe get the image path in the  function.

 

This is my code, tried to fill the TextBox9 with the image path, but not working properly:

 

Private Sub PictureBox4_ItemDataBinding(sender As Object, e As EventArgs) Handles PictureBox4.ItemDataBinding
        Dim picture As Telerik.Reporting.Processing.PictureBox = DirectCast(sender, Telerik.Reporting.Processing.PictureBox)

        Dim s As String = String.Format("= '{0}' + {1}", "/portals/0/PI/ProductImages/", TextBox9.Value.Replace("=", ""))

        picture.Image = Image.FromFile(s)
        TextBox13.Value = s
    End Sub

thanks

 

4 Answers, 1 is accepted

Sort by
0
Gustavo
Top achievements
Rank 1
answered on 28 Nov 2016, 06:03 AM

try to get in the code behind the value of the field with the path of the image. It doesn't return the value, just the column field

like:
C:\inetpub\wwwroot\JA Russell Full\1_DEV\DNN\= '\portals\0

\PI\ProductImages\' + Fields.ImageFileName

I just need a way to access the field in the DataSource of the current item in the data binding event

0
Stef
Telerik team
answered on 28 Nov 2016, 10:17 AM
Hi Gustavo,

The recommended approach is to use a custom function getting the field as a parameter. In the function you can implement the validation and return the correct path or if you prefer an Image object.

The above linked article contains an example.

Regards,
Stef
Telerik by Progress
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
Lucaso
Top achievements
Rank 1
answered on 29 Nov 2016, 02:08 AM

Hi Stef,

   we have same issue with the report image like the picture that I have attached. When picture load a product image if there are error it shows error massage.that is fine. But that error broke the report in to two pages, because the error message width is two big than image icon.and I gave tried set column width and Layout Sizing. It doesn't work.It just can not get ride of those error messages.

     Do you know any better way to hide ,or try catch,or show them in a small size? thanks 

 

-----------------------------------------------------------------------------

An error has occurred while processing PictureBox 'PictureBox4':
Invalid image data.
------------- InnerException -------------
Parameter is not valid

0
Stef
Telerik team
answered on 29 Nov 2016, 01:10 PM
Hi Lucaso,

The recommended approach is the same - use a custom function to validate the image data or return a default image instead. This will prevent red errors which can change the document layout.

Regards,
Stef
Telerik by Progress
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
General Discussions
Asked by
Gustavo
Top achievements
Rank 1
Answers by
Gustavo
Top achievements
Rank 1
Stef
Telerik team
Lucaso
Top achievements
Rank 1
Share this question
or