Syntax for ASPX markup to hide control based on NOT of boolean data item

In a repeater, I can use the following to display a control:

<asp:CheckBox ID="chkDelete" Runat="server" Visible='<%# DataBinder.Eval(Container.DataItem, "ShowFlag") %>' />

But what if I have two controls that are mutually exclusive so that one should show and the other should be hidden. For example,

<asp:CheckBox ID="chkDelete" Runat="server" Visible='<%# DataBinder.Eval(Container.DataItem, "ShowFlag") %>' />
<asp:Label ID="lblNothing" Runat="server" Visible='<%# NOT DataBinder.Eval(Container.DataItem, "ShowFlag") %>' >Nothing To Delete</asp:Label>

The last declaration using NOT doesn't work. Is it possible to do this inline?
LVL 1
ZekeLAAsked:
Who is Participating?
 
hehdaddyCommented:
Have you tried <%# !DataBinder.Eval... ?
0
 
guru_samiCommented:
My guess would be..
you might try doing that in Code behind ....in ItemDataBound event
0
 
ZekeLAAuthor Commented:
I'm looking for an inline solution. I know how to do it in Code Behind. Does anyone know if inline is possible for my situation?
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
ZekeLAAuthor Commented:
Hi HeyDaddy. I'm using VB  ( %@ Control Language="vb" ) and I already tried
  <%# NOT DataBinder.Eval(Container.DataItem  
which is the same but it didn't work.

Thanks anyway.
0
 
hehdaddyCommented:
Try something like this. Please forgive me if the syntax is wrong, I am away from my development machine.

Visible='<%# If Not DataBinder.Eval(Container.DataItem, "ShowFlag") = "True" Then "False" Else "True" End If %>'

or

Visible='<%# DataBinder.Eval(Container.DataItem, "ShowFlag") != "True" ? "False" : "True" %>'
0
 
guru_samiCommented:
This is something worked with C# ..try with VB:

Visible='<%# !Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "Discontinued"))%>'

'Discontinued' is a bit value in Database table.
0
 
guru_samiCommented:
So with VB it will be:
Visible='<%# NOT Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "ShowFlag"))%>'
0
 
ZekeLAAuthor Commented:
Well, the good news is that Convert.ToBoolean works.
The bad news is that my original statement appears to be wrong. <%# NOT DataBinder.Eval(Container.DataItem, "ShowFlag"))%> now works just fine.

I don't know if I had a syntax error originally or if something else was going on. Apologies to everyone. I've increased the points for the effort and spread them to those who had correct answers.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.