BinaryImage 'System.DBNull'

2 posts, 0 answers
  1. Kjell
    Kjell avatar
    195 posts
    Member since:
    May 2011

    Posted 23 Aug 2011 Link to this post

    I use BinaryImage in a RadListView (BinaryImage First Look example). Have problem if a Contact not have save image (BinaryImage)
    I get "Unable to cast object of type 'System.DBNull' to type 'System.Byte[]'."
    Tips on how I get around if a contact person chooses not to store their personal contact picture in the database?
    I use sql server 2008 and datatype varbinary(MAX)

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 24 Aug 2011 Link to this post

    Hello Kjell,

    Try the following markup which worked as expected in my end.
    <telerik:RadBinaryImage ID="photoOfUser" Style="float: left;" Width="160px" Height="200px" DataValue='<%#Eval("Photo") is DBNull ? null : Eval("Photo")%>' AutoAdjustImageControlSize="false" AlternateText="Photo" runat="server"></telerik:RadBinaryImage>

  3. DevCraft R3 2016 release webinar banner
Back to Top