Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: myListBox.SelectedItem is always null


Message #1 by "Minh T. Nguyen" <nguyentriminh@y...> on Wed, 13 Feb 2002 14:20:07 -0800
Hello there,



	I have a ListBox control and a button on my form. In the

button's click event I reference the myListBox.SelectedItem property,

but it turns out that this property is null, even though I have clearly

selected an item in the list box. At the same time,

myListBox.SelectedIndex is always -1.

	The myListBox has EnableViewState set to true. What am I

missing?



Thanks,

Minh.







_________________________________________________________



Do You Yahoo!?



Get your free @yahoo.com address at http://mail.yahoo.com







Message #2 by "McCloy, Russell" <Russell.McCloy@B...> on Thu, 14 Feb 2002 09:33:20 +1100
Hi Minh,



I have references ListBox selectedItem properties using:



	lsMatterType = lstMatterType.SelectedItem.text

	lsDisbType = lstDisbtype.selectedItem.value



Value or text.



Hope this helps.



RuSs



-----Original Message-----

From: Minh T. Nguyen [mailto:nguyentriminh@y...]

Sent: Thursday, 14 February 2002 9:20 AM

To: aspx_beginners

Subject: [aspx_beginners] myListBox.SelectedItem is always null





Hello there,



	I have a ListBox control and a button on my form. In the

button's click event I reference the myListBox.SelectedItem property,

but it turns out that this property is null, even though I have clearly

selected an item in the list box. At the same time,

myListBox.SelectedIndex is always -1.

	The myListBox has EnableViewState set to true. What am I

missing?



Thanks,

Minh.







_________________________________________________________



Do You Yahoo!?



Get your free @yahoo.com address at http://mail.yahoo.com












$subst('Email.Unsub').

Message #3 by "Minh T. Nguyen" <nguyentriminh@y...> on Wed, 13 Feb 2002 14:34:32 -0800
Russ,



	That's what I did at the beginning and I received a

NullPointerException since lstMatterType.SelectedItem was null. Hm..

I'll just have to continue playing with it.



Thanks,

Minh.



-----Original Message-----

From: McCloy, Russell [mailto:Russell.McCloy@B...] 

Sent: Wednesday, February 13, 2002 2:33 PM

To: aspx_beginners

Subject: [aspx_beginners] RE: myListBox.SelectedItem is always null





Hi Minh,



I have references ListBox selectedItem properties using:



	lsMatterType = lstMatterType.SelectedItem.text

	lsDisbType = lstDisbtype.selectedItem.value



Value or text.



Hope this helps.



RuSs







_________________________________________________________



Do You Yahoo!?



Get your free @yahoo.com address at http://mail.yahoo.com







Message #4 by "McCloy, Russell" <Russell.McCloy@B...> on Thu, 14 Feb 2002 09:44:16 +1100
interesting! Is there a chance that you are referencing the list

box before it is fully loaded? Now Im really guessing!

This shouldn't really be the case though as ASP.NET is OO and compiled 

unlike a script.



I give up.



sorry



RuSs









-----Original Message-----

From: Minh T. Nguyen [mailto:nguyentriminh@y...]

Sent: Thursday, 14 February 2002 9:35 AM

To: aspx_beginners

Subject: [aspx_beginners] RE: myListBox.SelectedItem is always null





Russ,



	That's what I did at the beginning and I received a

NullPointerException since lstMatterType.SelectedItem was null. Hm..

I'll just have to continue playing with it.



Thanks,

Minh.



-----Original Message-----

From: McCloy, Russell [mailto:Russell.McCloy@B...] 

Sent: Wednesday, February 13, 2002 2:33 PM

To: aspx_beginners

Subject: [aspx_beginners] RE: myListBox.SelectedItem is always null





Hi Minh,



I have references ListBox selectedItem properties using:



	lsMatterType = lstMatterType.SelectedItem.text

	lsDisbType = lstDisbtype.selectedItem.value



Value or text.



Hope this helps.



RuSs







_________________________________________________________



Do You Yahoo!?



Get your free @yahoo.com address at http://mail.yahoo.com












$subst('Email.Unsub').


  Return to Index