1

これはリピーターの私の td です。

<td>
<%#Convert.ToBoolean(Eval("IsDiscount")) ? (Eval("DiscountType").ToString() + " " + Eval("Product_Price_Discount").ToString()) : "No Discount"%>
</td>

選択条件が欲しい。それ以外の場合(Eval("DiscountType").ToString() is 1 display "Rupees" は「パーセンテージ」。

ie., if  IsDiscount true, and DiscountType=1  Display.. Rupees-150
  if  IsDiscount true, and DiscountType=2  Display. Percentage-5
4

1 に答える 1

1

たとえば、次のように、メソッドを作成し、コード ビハインドで条件付けを行うことができます。

<%# GetDiscountedPrice(Convert.ToBoolean(Eval("IsDiscount")), Convert.ToInt32(Eval("DiscountType"), Eval("Product_Price_Discount").ToString()) %> 

コード ビハインドには次のメソッドがあります。

protected string GetDiscountedPrice(bool IsDiscount, int DiscountType, string Product_Price_Discount)
{
    return IsDiscount ? (DiscountType == 1 ? "Rupees" : "Percentage") + " - " +  Product_Price_Discount : "No Discount"; 
}

このアプローチにより、よりクリーンな HTML が .aspx に含まれます。

お役に立てれば!

よろしく、 ウロス

于 2013-11-05T06:25:25.023 に答える