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. Advertising

  2. Roshawn

    Stan Guest

    On 21 Mar, 16:43, Roshawn <> wrote:
    > Hi,
    >
    > Working with the new ListView control seems pretty straightforward.  Forsome reason,
    > using ASP.NET's databinding syntax (i.e. <%# DataHere %>) in the control'slayouttemplate
    > 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


    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. Advertising

  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,
    RoshawnStan wrote:
    > On 21 Mar, 16:43, Roshawn <> wrote:
    >> 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

    >
    > You have to include the Eval("<column name>") or the Bind("<column
    > name>") function within the '<%# ... %> ' to actually retrieve or
    > ammend any data.
    >
    > HTH
     
    Roshawn, Mar 21, 2008
    #3
  4. Roshawn

    Stan Guest

    On 21 Mar, 18:27, Roshawn <> wrote:
    > Thanks for the response.  Unfortunately, even this doesn't work.  Fromwhat 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,
    >
    >
    >
    > RoshawnStan wrote:
    > > On 21 Mar, 16:43, Roshawn <> wrote:
    > >> 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

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

    >
    > > HTH- Hide quoted text -

    >
    > - Show quoted text -


    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).

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Wallace Breza, Jan 2, 2009
    #5
    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. =?Utf-8?B?VHlsZXIgQ2FydmVy?=

    Login Control LayoutTemplate Enter Key Event

    =?Utf-8?B?VHlsZXIgQ2FydmVy?=, Feb 6, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    6,140
    Steven Cheng[MSFT]
    Feb 7, 2006
  2. Roshawn
    Replies:
    0
    Views:
    255
    Roshawn
    Mar 21, 2008
  3. mesut
    Replies:
    3
    Views:
    785
    mesut
    Aug 12, 2008
  4. mat
    Replies:
    1
    Views:
    490
  5. .
    Replies:
    0
    Views:
    734
Loading...

Share This Page