Mounts link only when data is available

0

I have a webforms application. In this application I have this line in my ASP.NET.

<strong><a href="/UpLoads/<%# Eval("DsPathDocumento")%>" class="linkUpload"><%# Eval("NmTipoDocumento")%></a></strong>

Well, what I want is for this link to only mount when there is a document. I have done so and it is giving error that it is only possible within a Databound.

if(!String.IsNullOrEmpty(Eval("DsPathDocumento ").ToString())) { %>
                <<strong><a href="/UpLoads/<%# Eval("DsPathDocumento")%>" class="linkUpload"><%# Eval("NmTipoDocumento")%></a></strong>
                <% } %

>

How do I resolve this? This is the error:

Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
    
asked by anonymous 22.12.2014 / 13:13

1 answer

2

If you just want the link to be viewed or not, then use the Tag Style next to the Display property.

<strong>
    <a class="linkUpload" <%# Eval("SEQ_CHA") != null && !String.IsNullOrEmpty(Eval("SEQ_CHA").ToString()) ? String.Concat("href='/UpLoads/", Eval("SEQ_CHA"), "'") : "href='#' style='cursor: default; color:#000000;'" %>>
        <%# Eval("NmTipoDocumento")%>
    </a>
</strong>
    
22.12.2014 / 15:39