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

Issue with RadBinaryImage DataValue

1 Answer 78 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
sho
Top achievements
Rank 1
sho asked on 13 Dec 2011, 02:59 PM
Hi,

I have a RadBinaryImage control on my aspx page. using to display image.

I have stored my img file in sqldb as nvarbinary(max). I am retrieving the img from db table as byte[] and setting to RadBinaryImage control.

RadBinaryImage1.DataValue = imgsource;

imgsource is byte[].

But its throwing error as below.

Can any one tell me where am going wrong?

Thanks,

Parameter is not valid.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Parameter is not valid.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

1 Answer, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 14 Dec 2011, 06:34 PM
Hi Sho,

The Parameter is not valid error is thrown by the underling System.Drawing.Image object and signals that the supplied byte array cannot be converted to a valid image representation by the .NET framework's class. You may try this yourself by directly converting the bytes to an image and see if the error occurs. Using similar code:
using (var stream = new MemoryStream(bytes))
{
    // here the error in question will be thrown if bytes holds an invalid image
    var img = System.Drawing.Image.FromStream(stream);
}

The supported image types are bmp, jpeg, jpg, gif and png. If the image byte array is not formatted appropriately the error occurs.

Kind regards,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
General Discussions
Asked by
sho
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
Share this question
or