如何在aspx c#中使用EVAL条件使用IF ELSE

问题描述 投票:0回答:1

我正在尝试使用if else条件在aspx页面中使用Eval条件。但是它在else条件下显示错误红线,在)条件下显示if

代码

<div class="price_mth text-center">
<% if (string.IsNullOrEmpty(Eval("PromoPrice", "{0:,00}").ToString()) %>) { %>
<asp:panel id="pricePanel" runat="server" >
<h2><i class="fa fa-usd" aria-hidden="true"></i> <%# Eval("Price", "{0:,00}") %><sup>.00/mo</sup></h2>
</asp:panel>
 <% } %>

<% else { %>                                              
<asp:panel id="promopanel" runat="server">
<div class="style-1">
 <h2> <del><i class="fa fa-usd" aria-hidden="true"></i> <span class="amount"><%# Eval("Price", "{0:,00}") %></span> </del><sup>.00/mo</sup></h2>
 <h2><ins><i class="fa fa-usd" aria-hidden="true"></i> <span class="amount"><%# Eval("PromoPrice", "{0:,00}") %></span></ins><sup>.00/mo</sup></h2>
</div>
 </asp:panel>
<% } %>

c# asp.net eval
1个回答
0
投票

您可以如下使用methot

<asp:Panel ID="p1" Visible='<%#BLL.Logic.ShowPanel(Eval("PromoPrice", "{0:,00}")) %>' runat="server">

© www.soinside.com 2019 - 2024. All rights reserved.