如果使用其他与aspx页面的eval [英] using if else with eval in aspx page

查看:116
本文介绍了如果使用其他与aspx页面的eval的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有使用其他的方式,如果以下ASPX页面上的eval。

Is there a way to use an else if on the following eval on the aspx page .

目前我的分区如下:

  <div class="tooltip" style="display: none">                                                                  
        <div style="text-align: center; font-weight: normal">
                Value = <%# Eval("Percentage") + "%" %>     
        </div>
  </div>

我想用我的DIV以下逻辑:

I would like to use the following logic on my div :

If(Percentage < 50)
   display "0 %"
   else 
   display "percentage"

我想这样的事情,但它不工作:

I tried something like this but it doesn't work :

if (<%# Eval("Percentage") %> < 50)
{
    Eval("0");
}
else
{
   <%# Eval("PassPercentage") + "%" %> 
 }

我想知道,如果这样的操作是可能的aspx页面上完成。我不能做到这一点在aspx.cs。

I want to know if such an operation is possible to do on the aspx page. I cannot do it in aspx.cs.

推荐答案

如果你绝对不希望使用code-的背后,你可以尝试条件运算符为此:

If you absolutely do not want to use code-behind, you can try conditional operator for this:

<%# ((int)Eval("Percentage") < 50) ? "0 %" : Eval("Percentage") %>

这是假设字段百分比包含整数。

That is assuming field Percentage contains integer.

这篇关于如果使用其他与aspx页面的eval的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆