Home All Groups Group Topic Archive Search About

Set visibility of label in itemtemplate of repeater control

Author
16 Jan 2006 11:36 AM
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.

Author
17 Jan 2006 12:47 PM
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
Author
17 Jan 2006 1:10 PM
Stan
Hi Wouter,

That worked! How could I've missed that. Thanks!

Regards,

Stan.