Eval Syntax error

Kristopher Maier asked on January 26, 2017 22:11

I can get the following to work: <%# IfEmpty(Eval("EventWebsite"), "", "<a href=\"" + Eval("EventWebsite") + "\" class=\"applybttn\" target=\"_blank\">Website link</a>") %>

I would like to also load the name dynamically too. I have tried many combinations to get the "EventName" to show up but keep getting syntax errors. <%# IfEmpty(Eval("EventWebsite"), "", "<a href=\"" + Eval("EventWebsite") + "\" class=\"applybttn\" target=\"_blank\">{% Eval("EventName") %}</a>") %>

Can someone share what I am doing incorrectly?

Thank you

Correct Answer

Laura Frese answered on January 26, 2017 22:25

It looks like you are using a Transformation method to check if the EventWebsite value is empty but then you are using macro syntax to get the EventName. Proper would be like:

<%# IfEmpty(Eval("EventWebsite"), "", "<a href=\"" + Eval("EventWebsite") + "\" class=\"applybttn\" target=\"_blank\">" + Eval("EventName")+ "</a>") %>

0 votesVote for this answer Unmark Correct answer

Recent Answers


Kristopher Maier answered on January 27, 2017 14:42 (last edited on January 27, 2017 15:03)

Thank you! If I wanted to keep the Event Name even if there isn't a link how could I do that?

<li>
<p><strong><%# IfEmpty(Eval("EventWebsite"), "test to display event name", "<a href=\"" + Eval("EventWebsite") + "\" target=\"_blank\">" + Eval("EventName")+ "</a>") %></strong> - <%# Eval("EventLocation") %><br />
<%# Eval("EventDateDisplay") %><br />
<%# Eval("EventBoothSummary") %></p>

0 votesVote for this answer Mark as a Correct answer

Kristopher Maier answered on January 27, 2017 15:45 (last edited on January 27, 2017 15:46)

i figured it out

<li>
    <p><strong><%# IfEmpty(Eval("EventWebsite"), Eval("EventName"), "<a href=\"" + Eval("EventWebsite") + "\" target=\"_blank\">" + Eval("EventName") + "</a>") %></strong> - <%# Eval("EventLocation") %><br />
    <%# Eval("EventDateDisplay") %><br />
    <%# Eval("EventBoothSummary") %></p>
</li>
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.