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

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

1 Answer 140 Views
BinaryImage
This is a migrated thread and some comments may be shown as answers.
Canis Lupus
Top achievements
Rank 1
Canis Lupus asked on 24 May 2011, 01:06 PM
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.

1 Answer, 1 is accepted

Sort by
0
Canis Lupus
Top achievements
Rank 1
answered on 24 May 2011, 01:16 PM
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.
Tags
BinaryImage
Asked by
Canis Lupus
Top achievements
Rank 1
Answers by
Canis Lupus
Top achievements
Rank 1
Share this question
or