Hide when Empty. How to do this?

S

Shapper

Hello,

I have this code line inside an ASP.Net Repeater:
<a href='<%# DataBinder.Eval(Container.DataItem, "link") %>'><%=
readMore %></a>

What I need to do is:
1. Show readMore value if <%# DataBinder.Eval(Container.DataItem,
"link") %> is not empty.

2. Show nothing if <%# DataBinder.Eval(Container.DataItem, "link") %> is
empty.

In this moment it is showing all the time the value of readMore.

Or maybe just hide the <a> tag.

Is this possible?

Thanks,
Miguel
 
D

Dave Fancher

Both Azat and Gregory gave good possible solutions for this the last time
you asked. Personally, I'd prefer to filter out the rows where the value is
"empty" but if your solution doesn't allow for that, you can
programmatically hide the link during the ItemDataBound event
(http://msdn.microsoft.com/library/d...ebcontrolsrepeaterclassitemdataboundtopic.asp).

If you want to hide it by setting the link's Visible property to false or by
appending a display: none to its class attribute is up to you. Of course,
in order to access the link from the event handler, you'll have to either
set Runat="Server" on the link OR switch to using <asp:hyperlink ...>.
You'll also want to give the control an ID so you can easily access it
through FindControl().

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top