troubleshooting Question

Set image control to visible = false in datalist if pictureURL is null

Avatar of gogetsome
gogetsomeFlag for United States of America asked on
6 Comments1 Solution2093 ViewsLast Modified:
Hello, I have a datalist(see below) where I would like to set the image control visibility to false if ImageURL is null. How can this be accomplished?

  <asp:DataList ID="dlNewsArticle" runat="server" DataSourceID="dsNewsArticle">
                                <tr >
                                    <td   rowspan="2" style="width: 550px" valign="top">
                                        <asp:Image ID="imgNews" SkinID="padded"  runat="server" ImageUrl='<%#"~/News/image/" & Eval("PictureURL") %>' ImageAlign="Left" BorderColor="#F6E8B1" BorderStyle="Solid" BorderWidth="5px"/>
                                        <asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' Font-Bold="True"></asp:Label><br />
                                        <asp:Label ID="DateLabel" runat="server" Text='<%# Eval("Date") %>'></asp:Label><br />
                                        <asp:Label ID="lbl200" Text='<%# Replace(Eval("News"), chr(10), "<br/>") %>' runat="server"></asp:Label>
                </asp:DataList><asp:SqlDataSource ID="dsNewsArticle" runat="server" ConnectionString="<%$ ConnectionStrings:CountryConnectionString %>"
                    SelectCommand="SELECT [News], [Title], [Date], [PictureURL] FROM [News] WHERE (([Display] = @Display) AND ([ID] = @ID))">
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros