Radu Stanescu
Radu Stanescu

Reputation: 37

ASP if statement using databinder

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?

Upvotes: 0

Views: 901

Answers (1)

Sandeep
Sandeep

Reputation: 1210

You can use ternary operator:

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

Upvotes: 2

Related Questions