Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: another listbox problem


Message #1 by "Alex Smotritsky" <alex.smotritsky@v...> on Fri, 21 Feb 2003 03:59:49
I have a listbox that I'm populating programatically with Items from my db 
on page load. I have a button which onclick, references the selected item 
in this listbox. 

I started having the following problem:

Every time I click on the button, the list of items in the lisbox grows by 
the number of items I'm pulling from the db. This is because for every 
value I pull from the db, I create a new list item to add to the list.

I've tried to solve this problem by executing the following code before 
populating the list on page load:

ListBox1.Items.Clear();

This unfortunately causes the following error:

'Object reference not set to an instance of an object.'

This happens in the button click event in the line of code that's trying 
to get the selected value from the listbox.

I don't understand why this is happening. Right after I call 
ListBox1.Items.Clear();, I run the code that populates the list with 
values from the db. Any takers?
Message #2 by "Paul Riley" <rilez@t...> on Fri, 21 Feb 2003 11:01:45 -0000
Well it's difficult to know without seeing the code but you say that all
of this code is in page_load. Put it in a not ispostback if statement.
That way it will only run the first time. Like I say that might not be
what you're after but if you paste the code I'll have a look, Blind
leading the blind and all :)

-----Original Message-----
From: Alex Smotritsky [mailto:alex.smotritsky@v...] 
Sent: 21 February 2003 04:00
To: aspx_beginners
Subject: [aspx_beginners] another listbox problem


I have a listbox that I'm populating programatically with Items from my
db 
on page load. I have a button which onclick, references the selected
item 
in this listbox. 

I started having the following problem:

Every time I click on the button, the list of items in the lisbox grows
by 
the number of items I'm pulling from the db. This is because for every 
value I pull from the db, I create a new list item to add to the list.

I've tried to solve this problem by executing the following code before 
populating the list on page load:

ListBox1.Items.Clear();

This unfortunately causes the following error:

'Object reference not set to an instance of an object.'

This happens in the button click event in the line of code that's trying

to get the selected value from the listbox.

I don't understand why this is happening. Right after I call 
ListBox1.Items.Clear();, I run the code that populates the list with 
values from the db. Any takers?

Message #3 by "Dmitry Brook" <brook74@h...> on Fri, 21 Feb 2003 11:20:41 +0000
How do I unsubscribe "Alex Smotritsky' ???






>From: "Alex Smotritsky" <alex.smotritsky@v...>
>Reply-To: "aspx_beginners" <aspx_beginners@p...>
>To: "aspx_beginners" <aspx_beginners@p...>
>Subject: [aspx_beginners] another listbox problem
>Date: Fri, 21 Feb 2003 03:59:49
>
>I have a listbox that I'm populating programatically with Items from my db
>on page load. I have a button which onclick, references the selected item
>in this listbox.
>
>I started having the following problem:
>
>Every time I click on the button, the list of items in the lisbox grows by
>the number of items I'm pulling from the db. This is because for every
>value I pull from the db, I create a new list item to add to the list.
>
>I've tried to solve this problem by executing the following code before
>populating the list on page load:
>
>ListBox1.Items.Clear();
>
>This unfortunately causes the following error:
>
>'Object reference not set to an instance of an object.'
>
>This happens in the button click event in the line of code that's trying
>to get the selected value from the listbox.
>
>I don't understand why this is happening. Right after I call
>ListBox1.Items.Clear();, I run the code that populates the list with
>values from the db. Any takers?


_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail

Message #4 by "Alex Smotritsky" <alex.smotritsky@v...> on Fri, 21 Feb 2003 06:52:03 -0500
if (!IsPostBack) is the solution, thanks a lot Paul!


-----Original Message-----
From: Paul Riley [mailto:rilez@t...] 
Sent: Friday, February 21, 2003 6:02 AM
To: aspx_beginners
Subject: [aspx_beginners] RE: another listbox problem


Well it's difficult to know without seeing the code but you say that all
of this code is in page_load. Put it in a not ispostback if statement.
That way it will only run the first time. Like I say that might not be
what you're after but if you paste the code I'll have a look, Blind
leading the blind and all :)

-----Original Message-----
From: Alex Smotritsky [mailto:alex.smotritsky@v...] 
Sent: 21 February 2003 04:00
To: aspx_beginners
Subject: [aspx_beginners] another listbox problem


I have a listbox that I'm populating programatically with Items from my
db 
on page load. I have a button which onclick, references the selected
item 
in this listbox. 

I started having the following problem:

Every time I click on the button, the list of items in the lisbox grows
by 
the number of items I'm pulling from the db. This is because for every 
value I pull from the db, I create a new list item to add to the list.

I've tried to solve this problem by executing the following code before 
populating the list on page load:

ListBox1.Items.Clear();

This unfortunately causes the following error:

'Object reference not set to an instance of an object.'

This happens in the button click event in the line of code that's trying

to get the selected value from the listbox.

I don't understand why this is happening. Right after I call 
ListBox1.Items.Clear();, I run the code that populates the list with 
values from the db. Any takers?



Message #5 by "Jerry Lanphear" <jerrylan@q...> on Fri, 21 Feb 2003 08:29:14 -0700
Dmitry,

Your email program, whether it is Outlook or Outlook express or some
other should have an email rules section with which you can have emails
erased before they show based on the sender and also other things.

However, I can not imagine why you feel this person is unworthy of
entering your email box. We all are at different levels.  This forum is
"[aspx_beginners]" Maybe you should subscribe to the
"[aspx_ImSoHot_I_DontNeedAlex]" forum. 

Regards

-----Original Message-----
From: Dmitry Brook [mailto:brook74@h...] 
Sent: Friday, February 21, 2003 4:21 AM
To: aspx_beginners
Subject: [aspx_beginners] Re: another listbox problem

How do I unsubscribe "Alex Smotritsky' ???






>From: "Alex Smotritsky" <alex.smotritsky@v...>
>Reply-To: "aspx_beginners" <aspx_beginners@p...>
>To: "aspx_beginners" <aspx_beginners@p...>
>Subject: [aspx_beginners] another listbox problem
>Date: Fri, 21 Feb 2003 03:59:49
>
>I have a listbox that I'm populating programatically with Items from my
db
>on page load. I have a button which onclick, references the selected
item
>in this listbox.
>
>I started having the following problem:
>
>Every time I click on the button, the list of items in the lisbox grows
by
>the number of items I'm pulling from the db. This is because for every
>value I pull from the db, I create a new list item to add to the list.
>
>I've tried to solve this problem by executing the following code before
>populating the list on page load:
>
>ListBox1.Items.Clear();
>
>This unfortunately causes the following error:
>
>'Object reference not set to an instance of an object.'
>
>This happens in the button click event in the line of code that's
trying
>to get the selected value from the listbox.
>
>I don't understand why this is happening. Right after I call
>ListBox1.Items.Clear();, I run the code that populates the list with
>values from the db. Any takers?


_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail






  Return to Index