Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
613 views
in Technique[技术] by (71.8m points)

asp.net - #Eval if statement in repeater

I'm trying to check a string value inside a repeater, and if it has value then write a link, but can't seem to get it to work. If there is a value in myUrl then I want to display the link.

 <%if( %> <%#Eval("myURL").ToString().Length > 0 %>
       <a  title="myTitle" target="_blank" href="<%# Eval("myURL") %>">my link</a>                  
 <% } %>

Can anyone please help?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

try this code !!!

<%#Eval("myURL").ToString().Length > 0 ?
"<a  title='myTitle' target='_blank' href='<%# Eval("myURL") %>'>my link</a>":""%>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...