Listview Loading Twice...

Last post 06-27-2009 6:37 AM by superguppie. 11 replies.

Sort Posts:

  • Listview Loading Twice...

    06-25-2009, 11:31 AM
    • Member
      point Member
    • lsimpson09
    • Member since 03-05-2009, 2:00 PM
    • Posts 5

    I have a form inside of a masterpage content area that is using the postbackurl to submit to another page.  On the other page is a listview with an objectdatasource.  When that 2nd page is loaded, the listview gets loaded twice (as watched through debug -- the objectdatasource onselecting fires twice, listview databound fires twice, etc...).

    If I place the same form on the masterpage itself (ie. not in a content area) and submit to that other page, the listview only loads once.

    Any suggestions to this problem?

    Thanks,

    Lee

  • Re: Listview Loading Twice...

    06-25-2009, 12:59 PM
    • Star
      8,852 point Star
    • integrasol
    • Member since 06-05-2009, 11:18 AM
    • Denmark & Spain
    • Posts 1,643

    Not usre if I get this right; you have the master page with the form element inside a ContentPlaceHolder control? Is the form a server side control (runat="server")? Is the second page a content page or a stndard Web Form?

    Thanks

    Carsten

    Please click Mark as Answer if this post is of help to you. :-)



    My Blog
  • Re: Listview Loading Twice...

    06-25-2009, 1:27 PM
    • Member
      point Member
    • lsimpson09
    • Member since 03-05-2009, 2:00 PM
    • Posts 5

    No - the form element is outside the contentplaceholder and yes, it's a server side control.  The second page is a content page.  I added a simple layout below - see if that helps.

    Sorry for the confusion.

    ============================

    Master:
    ...
    <form...>
    <asp:contentplaceholder id="content"...>
    </form>
    ...

    Page 1:
    ...
    <asp:Content ...>
    <asp:TextBox...>
    <asp:ImageButton PostBackURL="~/page2.asp"...>
    </asp:Content>

    Page 2:
    ...
    <asp:Content ...>
    <asp:ListView...>
    <asp:ObjectDataSource...>
    </asp:Content>

  • Re: Listview Loading Twice...

    06-25-2009, 3:46 PM
    • Star
      8,852 point Star
    • integrasol
    • Member since 06-05-2009, 11:18 AM
    • Denmark & Spain
    • Posts 1,643

    Okay, I think we're on the same page now, pun intented. ;-)

    The loading of a page and databound controls may have to do with one or more incorrectly defined HTML elements on the offending page. This can cause your browser to request the page more than once. Have you checked the markup in page 2 compared to what you have in page 1?

    I'll be happy to go over your markup, if you want?

    Thanks

    Carsten

    Please click Mark as Answer if this post is of help to you. :-)



    My Blog
  • Re: Listview Loading Twice...

    06-25-2009, 5:07 PM
    • Member
      point Member
    • lsimpson09
    • Member since 03-05-2009, 2:00 PM
    • Posts 5

    The pages are not publically accesible else I'd love for you to take a look...  What should I be looking for?  What page should I consider the offending page (master, page1 or page2)?

    In watching debug, I noticed that Page_Load only gets fired once. So the sequence is something like:
    Page_Load
    ObjectDataSource_Selecting
    ListView_ItemDataBound
    (immediatly back to)
    ObjectDataSource_Selecting
    ListView_ItemDataBound

    I don't know helps at all...

  • Re: Listview Loading Twice...

    06-26-2009, 1:52 AM
    • Star
      8,852 point Star
    • integrasol
    • Member since 06-05-2009, 11:18 AM
    • Denmark & Spain
    • Posts 1,643

    Well, if your problem is with page 2 only, or rather a combination of the master page and content page 2, then your beef should be with page 2. In any case, I think you might want to check properties that are set or not set, missing closing tags and stuff like that. Potentially start with the ImageButton and then all of the markup on page 2.

    Thanks

    Carsten

    Please click Mark as Answer if this post is of help to you. :-)



    My Blog
  • Re: Listview Loading Twice...

    06-26-2009, 10:59 AM
    • Contributor
      7,023 point Contributor
    • superguppie
    • Member since 05-19-2009, 7:42 AM
    • Posts 1,240
    Do you DataBind from code? Or do you let ASP do it all for you?
    Superguppie.

    Please remember to click “Mark as Answer” on the post that helps you.
    This can be beneficial to other community members reading the thread.

    When all you've got is a Hammer,
    Every Problem looks like a Nail.
    Michael Swain.
  • Re: Listview Loading Twice...

    06-26-2009, 12:38 PM
    • Member
      point Member
    • lsimpson09
    • Member since 03-05-2009, 2:00 PM
    • Posts 5

    superguppie:
    Do you DataBind from code? Or do you let ASP do it all for you?

    ASP.net does it all - there is no databind in codebehind.

  • Re: Listview Loading Twice...

    06-26-2009, 1:52 PM
    • Contributor
      2,776 point Contributor
    • RichardD
    • Member since 09-03-2002, 11:43 AM
    • Sussex, UK
    • Posts 364

    It's probably related to this bug in the ListView control when bound to a data-source control. If you manually call DataBind on the ListView or any parent control, or if the ListView is nested within another data-bound control, the select method of the data source control will be called twice.

    The bug has been marked as "fixed", so hopefully .NET 4 will not have this problem. Until then, the workaround is to wrap the ListView in a container which will prevent the parent DataBind method from affecting the ListView.

  • Re: Listview Loading Twice...

    06-27-2009, 6:12 AM
    • Contributor
      7,023 point Contributor
    • superguppie
    • Member since 05-19-2009, 7:42 AM
    • Posts 1,240
    Hmmmm, now I am really curious about the masterpage and subpage. I have a webapplication using masterpages and even nested masterpages a lot. Haven't noticed any performance issues. But if there is repeated binding, I want to know about it. I'll have a look at that on monday. (when at work again)
    Superguppie.

    Please remember to click “Mark as Answer” on the post that helps you.
    This can be beneficial to other community members reading the thread.

    When all you've got is a Hammer,
    Every Problem looks like a Nail.
    Michael Swain.
  • Re: Listview Loading Twice...

    06-27-2009, 6:15 AM
    • Star
      8,852 point Star
    • integrasol
    • Member since 06-05-2009, 11:18 AM
    • Denmark & Spain
    • Posts 1,643

    So, you're not working over the weekend? Alright for some, eh? Wink

    Thanks

    Carsten

    Please click Mark as Answer if this post is of help to you. :-)



    My Blog
  • Re: Listview Loading Twice...

    06-27-2009, 6:37 AM
    • Contributor
      7,023 point Contributor
    • superguppie
    • Member since 05-19-2009, 7:42 AM
    • Posts 1,240
    Yeah. Lucky me.

    And rethinking my last post. I don't think we use ListView. GridView is the one if I remember correctly.
    That will be another "Lucku me". :D
    Superguppie.

    Please remember to click “Mark as Answer” on the post that helps you.
    This can be beneficial to other community members reading the thread.

    When all you've got is a Hammer,
    Every Problem looks like a Nail.
    Michael Swain.
Page 1 of 1 (12 items)