这是我在复发器的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发布于 2013-11-05 06:25:25
您可以创建一个方法,并在代码隐藏中进行调整,例如:
<%# 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";
}使用这种方法,您的.aspx中有一个更干净的HTML
希望这能有所帮助!
你好,乌罗斯
https://stackoverflow.com/questions/19782509
复制相似问题