0

I have the following code which displays some info inside a table in ASP :

<td class="s10"><%# DataBinder.Eval(Container.DataItem, "VTarget")%></td>
<td class="s10"><%# DataBinder.Eval(Container.DataItem, "QTarget")%></td>

I want to compare the information from VTarget and QTarget and if the second is greater than the first i want to display a message.

Is there any way to do that using something like an if {...} else {...} statement?

1 Answer 1

2

You can use ternary operator:

   <td class="s10"><%# Convert.ToInt32(DataBinder.Eval(Container.DataItem, "QTarget")) > Convert.ToInt32(DataBinder.Eval(Container.DataItem, "VTarget")) ? "Message": "" %></td>
Sign up to request clarification or add additional context in comments.

2 Comments

It provides me the follwing error "Operator '>' cannot be applied to operands of type 'object' and 'object'"
@RaduStanescu try to use Convert.ToInt32 or which ever datatype you are using

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.