How to check two condition with aspx inline code

223 Views Asked by At

I am getting a value from database with using Eval("price"), i am checking if price is empty or null but i would like to check if price is equal to the zero or bigger than zero condition at the same time.

I am checking IsNullOrEmpty with this code:

<%# String.IsNullOrEmpty(Eval("price").ToString()) ? "Not Available" : Eval("price").ToString() %>

I would like to check if(price = 0) say free or else if(price > 0) than show price condition at the same time and show message.

<%# Eval("price").ToString() == "0" ? "FREE" : Eval("price").ToString() %> // Not working

Is it possible to check isnullorempty and price in same inline code?

1

There are 1 best solutions below

0
Zakk Diaz On BEST ANSWER

You're only checking is null or empty, it doesn't check if price is 0. Try something like

<%# String.IsNullOrEmpty(Eval("price").ToString()) ? "Not Available" : Eval("price").ToString() == "0" ? "FREE" : Eval("price").ToString() %>