Issue with RadBinaryImage DataValue

2 posts, 0 answers
  1. sho
    sho avatar
    24 posts
    Member since:
    Mar 2007

    Posted 13 Dec 2011 Link to this post


    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?


    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.
  2. Antonio Stoilkov
    Antonio Stoilkov avatar
    530 posts

    Posted 14 Dec 2011 Link to this post

    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
  3. DevCraft R3 2016 release webinar banner
Back to Top