How to hide this?

S

Shapper

Hello,

I have this in a Repeater on na Asp.Net page:
<a href='<%# DataBinder.Eval(Container.DataItem, "link") %>'>Go</a>

How to hide everything is the link field is empty?

Thanks,
Miguel
 
A

Azat Chafigoulline

I'd just add check for the link being empty, and if it's true then set the
style "display:none" within the "<a>" tag. It would look like this:
<%
//Define a function to check the value and return the "none" or ""
attribute for "display"
string HideLink ( val )
{
return (val== null || val=="")?"none":"");
}
%>


I haven't tested it, so I'm not sure about the syntax, but just try it.

Azat
 
G

Guest

Choices:

1. Filter the data to ensure only those with valid links are bound.
2. Move away from declarative binding and create the links programatically
and then bind them to a container (panel comes to mind).
3. If this is a single row, you can make the repeater invisibible when the
value is empty.

These are the first ideas that come to mind. Of the ideas, #1 is my favorite
as it filters out junk and does not process it at all.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 

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,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top