我在ASP.NET网页中有这样的代码,但是当我运行它时出现错误。Eval()和表达式代码
> Databinding methods such as Eval(), XPath(), and Bind() can only
> be used in the context of a databound control.
问题在哪里?
<% if (Helpers.GetInt(Eval("Price")) != 0)
{ %>
<input type="button" name="btnSignUp" value="Sign Up - Plimus »" onclick="window.location='<%#Eval("BuyUrl2")%><%= Common.GetUserIdUrl("&","custom_user_id") %>'" />
<% } %>
我得到线错误代码
<%,如果(Helpers.GetInt(EVAL( “价格”))!= 0)
我完全直放站代码如下。正如我早说的,除了IF
声明外,此代码中的所有内容均可正常工作。我想评估PRICE
,如果是!=0
显示按钮的html代码。
<ItemTemplate>
<div class="row">
<div class="col title">
<%#Eval("Title")%>
</div>
<hr/>
<div class="col price">
<%#string.Format("{0} USD/{1} </br> Instant activation", Helpers.GetDecimal(Eval("Price")).ToString("N"), Portal.GetMembershipTypeLabel(Helpers.GetInt(Eval("Credits"))))%>
</div>
<div class="col">
<input type="button" name="btnSignUp" value="Sign Up - PayPal »" onclick="window.location='<%#Eval("BuyUrl1")%><%= Common.GetUserIdUrl("&","custom_user_id") %>'" />
<br />
<br />
<% if (Helpers.GetInt(Eval("Price")) != 0)
{ %>
<input type="button" name="btnSignUp" value="Sign Up - Plimus »" onclick="window.location='<%= Eval("BuyUrl2")%><%= Common.GetUserIdUrl("&","custom_user_id") %>'" />
<% } %>
</div>
<hr/>
</div>
</ItemTemplate>
你尝试:'<%=的eval( “BuyUrl2”)%>'呢? – Icarus
@Icarus IF线出现异常 – Tomas
Tomas能否显示完整的aspx文件? –