Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Hide HyperLink if Database cell is NULL

$
0
0

Hi,

I have a database table which contains two columns (a and b).

I have a page which displays links to document files in these two columns:

<asp:HyperLink ID="HyperLinkA" runat="server" NavigateUrl='<%# string.Format("/downloads/A/{0}", Eval("a")) %>' Text="Download A"></asp:HyperLink><br /><asp:HyperLink ID="HyperLinkB" runat="server" NavigateUrl='<%# string.Format("/downloads/B/{0}", Eval("b")) %>' Text="Download B"></asp:HyperLink>

(This is a simplified version of what's really there.)

These HyperLinks are contained within the ItemTemplate of a ListView which is populated from a SqlDataSource (SELECT products.a, products.b. etc.) For some rows in "products", there will be both an "a" file and a "b" file; for some there will be one or the other; for some there will be neither.

****

OK, requirement is simple: If there is a value in the table for the Link (see Eval above), disply the HyperLink; if not, hide the HyperLink.

I use C# but not sure best way to tackle this.

Thanks.

 


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>