Set visibility of label in itemtemplate of repeater control

Discussion in 'ASP .Net Web Controls' started by Stan, Jan 16, 2006.

  1. Stan

    Stan Guest

    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.
    Stan, Jan 16, 2006
    #1
    1. Advertising

  2. 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
    Wouter van Vugt, Jan 17, 2006
    #2
    1. Advertising

  3. Stan

    Stan Guest

    Hi Wouter,

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

    Regards,

    Stan.
    Stan, Jan 17, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lerp

    itemtemplate visibility

    Lerp, May 10, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    551
  2. Bennett Haselton
    Replies:
    1
    Views:
    5,332
    Joe Fallon
    Sep 24, 2004
  3. Replies:
    3
    Views:
    1,591
    Eliyahu Goldin
    Aug 16, 2005
  4. Replies:
    3
    Views:
    435
  5. Knut Krueger
    Replies:
    8
    Views:
    265
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page