handling page load event

Discussion in 'ASP .Net' started by Carlos, May 22, 2006.

  1. Carlos

    Carlos Guest

    Hi all,

    I populate a list box during the page load
    event, and I do it within the if (not page.postback())
    condition. However, I do notice that the
    list gets duplicated. When I debug the app, I certainly
    go twice thru the logic, before the page displays.
    I though that I could just be able to populate the
    list when the page goes through the logic one time.
    I do not know why is doing it twice.

    Thanks in advance for any help.

    Carlos.
     
    Carlos, May 22, 2006
    #1
    1. Advertising

  2. Carlos

    jimmy Guest

    Is your page inheriting from some master page ??
     
    jimmy, May 22, 2006
    #2
    1. Advertising

  3. Carlos

    Mark Rae Guest

    "Carlos" <> wrote in message
    news:...

    > I populate a list box during the page load
    > event, and I do it within the if (not page.postback())
    > condition. However, I do notice that the
    > list gets duplicated. When I debug the app, I certainly
    > go twice thru the logic, before the page displays.
    > I though that I could just be able to populate the
    > list when the page goes through the logic one time.
    > I do not know why is doing it twice.
    >
    > Thanks in advance for any help.


    Firstly, don't populate "reference" objects like listviews, dropdowns etc in
    Page_Load - do it in Page_Init instead.

    Secondly, are you populating the listview item by item i.e. by using the
    Items.Add or Items.Insert methods rather than binding its DataSource
    property to an ADO.NET object? If so, make sure you clear the items first by
    invoking the Items.Clear() method, otherwise you'll duplicate the items
    every time you postback.
     
    Mark Rae, May 22, 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. WFB
    Replies:
    1
    Views:
    2,635
    Charlie Nilsson [MSFT]
    Dec 30, 2003
  2. =?Utf-8?B?QWxpcmV6YSBaaWFp?=

    PreRender Event occurs immediatley after Load event

    =?Utf-8?B?QWxpcmV6YSBaaWFp?=, Feb 9, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,118
    Hans Kesting
    Feb 9, 2004
  3. venky

    Page Load and webcontrol page load

    venky, Jul 6, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    3,107
    venky
    Jul 11, 2005
  4. GauravGupta
    Replies:
    4
    Views:
    2,109
    Shilpa1234
    Jan 19, 2012
  5. Matcon
    Replies:
    3
    Views:
    21,582
    Matcon
    May 28, 2008
Loading...

Share This Page