Last post Mar 25, 2020 04:04 PM by KathyW
Mar 25, 2020 03:34 PM|Dedegan|LINK
I combine 3 tables into one repeater component and do databind operation. There are 5 fields in the repater where I write data with the Eval () function. one of them is asp: Image object .my
pictures database is designed in this way. img1, img2, img3, img4 ... If the picture is left blank or deleted, for example, the first picture on the saved page, I save it to the database as zero. With the eval
function, for example, I want to set the value from the first image in the database to asp: image object. If the first value is registered as zero, I would like to show a picture that I have determined previously instead of this value.
Mar 25, 2020 04:04 PM|KathyW|LINK
Assuming the value in your database is a string, even if it is 0, that "imagefile" is the name of your database field with a full path to the image, and that "defaultimage.jpg" is the full path to the default image when the "imagefile" value is "0". Adjust
to your actual names and values.
<asp:Image ID="image1" runat="server" ImageUrl='<%# (string)Eval("imagefile")=="0"? "defaultimage.jpg" : Eval("imagefile") %>' ></asp:Image>