Hello,
I have a database where the user may upload an alternative image for a device.
If the image is not present in the database, the datasource returns a DBNull and the binary image should show the standard image file from the servers image directory.
I used this code which works fine if the image is not present.
If the database returns the image I get this error message during the page creation:
"Cannot set image Url if DataValue is already set"
If I remove the ImageUrl property, the image of the database is shown properly. So it's surely not a corrupted image file.
I am currently using the following workaround:
Is it possible to set DataValue and the alternative ImageUrl Property of a single RadBinaryImage?
I would expect the RadBinaryImage to ignore the ImageUrl if DataValue has data.
UPDATE
Forget about the thread.
Simply swapping the order of ImageUrl and DataValue did the trick. :)
I have a database where the user may upload an alternative image for a device.
If the image is not present in the database, the datasource returns a DBNull and the binary image should show the standard image file from the servers image directory.
I used this code which works fine if the image is not present.
<
telerik:RadBinaryImage
ID
=
"RadBinaryImage1"
runat
=
"server"
DataValue='<%# Eval("Data") is DBNull ? null : Eval("Data")%> '
AlternateText=" " AutoAdjustImageControlSize="true"
ImageUrl='<%# Eval("Type", "~/Images/Devices/{0}_sml.png") %>'
Width="64px" Height="64px" ImageAlign="Middle" ResizeMode="Fit" />
If the database returns the image I get this error message during the page creation:
"Cannot set image Url if DataValue is already set"
If I remove the ImageUrl property, the image of the database is shown properly. So it's surely not a corrupted image file.
I am currently using the following workaround:
<
telerik:RadBinaryImage
ID
=
"DeviceBinaryImage"
runat
=
"server"
DataValue='<%# Eval("Data") is DBNull ? null : Eval("Data")%> '
AlternateText=" " AutoAdjustImageControlSize="true"
Visible='<%# Eval("Data") is DBNull ? false : true %>'
Width="64px" Height="64px" ImageAlign="Middle" ResizeMode="Fit" />
<
asp:Image
ID
=
"Image1"
runat
=
"server"
ImageUrl='<%# Eval("Type", "~/Images/Devices/{0}_sml.png") %>'
Visible='<%# Eval("Data") is DBNull ? true : false %>' />
Is it possible to set DataValue and the alternative ImageUrl Property of a single RadBinaryImage?
I would expect the RadBinaryImage to ignore the ImageUrl if DataValue has data.
UPDATE
Forget about the thread.
Simply swapping the order of ImageUrl and DataValue did the trick. :)