Set visibility of label in itemtemplate of repeater control

S

Stan

Hi all! I'm trying to set the visibilty of a label in the itemtemplate
of a repeater control. The repeater is bound to a datatable. It is
possible that a row of this datatable is empty, in that case I would
like to hide the label, not within my code-behind but within the 'aspx'
(because the label is part of the itemtemplate it gets rendered in the
following format 'UserControlId_RepeaterId_counter_LabelId).

So I tried this (after searching several newsgroups):

visible=<%# (DataBinder.Eval(Container,
"DataItem.Instantie_naam").Equals(String.Empty)) ? "false" : "true" %>

I can't get this to work, an ASP.NET error message is displayed in my
browser:

CS0030: Cannot convert type 'string' to 'bool'

Anybody any ideas? Thanks in advance!

Regards,

Stan.
 
W

Wouter van Vugt

Hi Stan,

you are using dotNET code inside the DataBinder.Eval, hence a "true" is
seen as a string (which it indeed is). You should use true and false
without the ".

visible=<%# (DataBinder.Eval(Container,
"DataItem.Instantie_naam").Equals(String.Empty)) ? false : true %>

Grtz, Wouter van Vugt
Trainer - Info Support
blogs.infosupport.com/wouterv
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top