Databinding Syntax Not Working in ListView LayoutTemplate

Discussion in 'ASP .Net Web Controls' started by Roshawn, Mar 21, 2008.

  1. Roshawn

    Roshawn Guest

    Hi,

    Working with the new ListView control seems pretty straightforward. For some reason,
    using ASP.NET's databinding syntax (i.e. <%# DataHere %>) in the control's layouttemplate
    doesn't work. Is there any way of making it work? If not, is it possible to create a
    derived control that enables this functionality?

    Thanks,
    Roshawn
     
    Roshawn, Mar 21, 2008
    #1
    1. Advertisements

  2. Roshawn

    Stan Guest

    You have to include the Eval("<column name>") or the Bind("<column
    name>") function within the '<%# ... %> ' to actually retrieve or
    ammend any data.

    HTH
     
    Stan, Mar 21, 2008
    #2
    1. Advertisements

  3. Roshawn

    Roshawn Guest

    Thanks for the response. Unfortunately, even this doesn't work. From what I've read,
    it's not possible to bind to anything within the ListView's layouttemplate. It's strange
    that I can do so in a master page and pretty much anywhere else except here.

    I'm open to any more suggestions.

    Thanks,
     
    Roshawn, Mar 21, 2008
    #3
  4. Roshawn

    Stan Guest

    Ahh! Sorry I misunderstood.

    The answer to your question is probably no. The LayoutTemplate is
    purely to define the overall structure and appearence of the control
    not to render any actual data. All databound elements have to go in
    the ItemTemplate, AlternatingItemtemplate etc

    If you tell us a bit more about what you are trying to do it may be
    possible to suggest alternatives.
     
    Stan, Mar 21, 2008
    #4
  5. You can subscribe to the "LayoutCreated" event within the
    ListView control. Within the event handler, cast the
    sender to the ListView, perform a FindControl(id) for the
    control within the LayoutTemplate that you want to
    manipulate and programatically databind your control(s).
     
    Wallace Breza, Jan 2, 2009
    #5
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.