Sami
Sami

Reputation: 3976

ternary operator in ascx page

I have this check in ListView

<%# Eval("Count") != null ? Eval("Count") : 0%>/<%# Eval("MaxRange")%>

now i want to change that if count is null then it should show nothing.

I tried this but no avail.

<%# Eval("Count") != null ? Eval("Count") + '/' + <%# Eval("MaxRange")%> : null %>

Please let me know how to do this.

Thanks.

Upvotes: 0

Views: 2385

Answers (3)

Amritpal Singh
Amritpal Singh

Reputation: 1785

try this

    <%# Eval("Count") != null ? Eval("Count") + '/' +  Eval("MaxRange") : ""%>

I think this should work

Upvotes: 1

Sandeep Pathak
Sandeep Pathak

Reputation: 10767

<%# Eval("Count") != null ? Eval("Count") + '/' + <%# Eval("MaxRange")%> : String.Empty%>

Upvotes: 0

Null Pointer
Null Pointer

Reputation: 9309

try this

<%# Eval("Count") != null ? Eval("Count") + '/' + <%# Eval("MaxRange")%> : ""%>

Upvotes: 0

Related Questions