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

BinaryImage 'System.DBNull'

1 Answer 70 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Kjell
Top achievements
Rank 1
Iron
Kjell asked on 23 Aug 2011, 02:54 PM

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)

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 24 Aug 2011, 02:07 PM
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>

Thanks,
Shinu.
Tags
ListView
Asked by
Kjell
Top achievements
Rank 1
Iron
Answers by
Shinu
Top achievements
Rank 2
Share this question
or