Unable to cast object of type 'System.DBNull' to type 'System.Byte[]'.

2 posts, 0 answers
  1. Canis Lupus
    Canis Lupus avatar
    9 posts
    Member since:
    Aug 2012

    Posted 24 May 2011 Link to this post

    This is how I formed my control

    <telerik:RadBinaryImage ID="imageThumbnail" runat="server" DataValue='<%# Eval("imageThumbData") %>' ImageUrl="~/imageLibrary/common/nopic.gif" Width="125" Height="125" />

    When I run the application I get an error saying

    Unable to cast object of type 'System.DBNull' to type 'System.Byte[]'.


    Isnt the imageURL suppose to handle this null case? How can I fix it?

    Thank you.
  2. Canis Lupus
    Canis Lupus avatar
    9 posts
    Member since:
    Aug 2012

    Posted 24 May 2011 Link to this post

    Solved it from other posts.

    <telerik:RadBinaryImage ID="imageThumbnail" runat="server" DataValue='<%#IIf(Typeof(Eval("imageThumbData")) is DBNull, Nothing, Eval("imageThumbData"))%>' ImageUrl="~/imageLibrary/common/loading.gif" Width="125" Height="125" />

    Above code works for me.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top