Stanfrancisco
Stanfrancisco

Reputation: 352

If statement, or some conditional inside asp:repeater BuildLink (multiple evals)

I need to make some sort of conditional when the eval returns nothing. Currently it creates a link "My Link" That leads to nowhere when the url is blank. I would prefer the "My Link" to not show up at all when the url is blank.

I've tried to implement something like what is found in the first answer to this question...#Eval if statement in repeater but either the buildlink() or the multiple eval() statements are throwing me some errors.

Here is the code I currently have

<asp:HyperLink runat="server"  
NavigateUrl='<%# BuildLink(Eval("TaskDefinition.Url").ToString(), Eval     ("TaskInstanceID").ToString())%>'>
My Link    
</asp:HyperLink>  

Upvotes: 0

Views: 92

Answers (1)

Yuri
Yuri

Reputation: 2900

you need to add visibility attribute

<asp:HyperLink runat="server"  
NavigateUrl='<%# BuildLink(Eval("TaskDefinition.Url").ToString(), Eval("TaskInstanceID").ToString())%>'  
Visible='<%# String.IsNullOrEmpty(BuildLink(Eval("TaskDefinition.Url").ToString(), Eval("TaskInstanceID").ToString())) %>'
>My Link   
</asp:HyperLink>

Upvotes: 1

Related Questions