handling page load event

C

Carlos

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

Mark Rae

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.
 

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

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top