hi according to this thread
http://www.aspforums.net/Threads/370912/Hide-the-Image-Control-in-DataList-if-image-does-not-exist-in-DataBase/
i thought that it solved my problem but when i test it again i found that it didn't work correctly
it didn't show div
if there was image or there wasn't image in database it didn't show div
i want it doesn't show div if there wasn't any image in database
thanks
You need to decide what is the value stored if image is not present. it is not working because that person checks for null and if you have blank in database the condition will fail
i want check for null if image was null in database it doesn't show div
here didn't show div i checked both position
1-there was null in database
2-there was an image in database in both position didn't show div
Share the datalist html
<asp:DataList ID="DDLC" runat="server"> <ItemTemplate> <div id="Dmainart"> <div id="Dart1"> <div id="Dart1_1"> <div id="Dart1_12"> <div id="Dart1_I1" runat="server" visible='<%# !string.IsNullOrEmpty(Eval("image2").ToString())%>'> <a href='<%#Eval("image2","../image/house/article/image/{0}")%>' title='<%#Eval("name")%>' class="thickbox"> <asp:image ID="image1" runat="server" CssClass="TPH" ImageUrl='<%#Eval("image2","image/house/article/image/{0}")%>' Width="90px" Height="64px"/> </a> </div> <div id="Dart1_I2" runat="server" visible='<%# !string.IsNullOrEmpty(Eval("image").ToString())%>'><a href='<%#Eval("image1","../image/house/article/image/{0}")%>' title='<%#Eval("name")%>' class="thickbox"> <asp:image ID="image2" runat="server" CssClass="TPH" ImageUrl='<%#Eval("image1","image/house/article/image/{0}")%>' Width="90px" Height="64px"/> </a> </div> </div>
in 13 th line of the above code div with id "Dart1_I2" is made visible on the bases of of "image" column while in the link inside the same div you are binding the different column ...viz., "image1" shouldnt it both be either "image" or "image1.....?"
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.