listbox.selectedvalue does not return anything

  • Thread starter Thread starter John O'Donnell
  • Start date Start date
J

John O'Donnell

Hello

on my asp.net code I load up a listbox on the page_load method. The problem
is that while the items I have added in the page_load do appear when i run
the page, i am unable to get the value of the selected item using
listbox.selectedvalue etc.

somehow the server side is unaware that i have selected an item.

In fact if i set the listbox.selecteditem=0; it always returns this item
even though i have selected another item.

any ideas?

thanks!!
 
in my page load i use this
if{!this.ispostback)
{
populate listbox etc
}

however when i click the button this listbox blanks out and i do not get a
value back.

As i load the listbox using the page_load surely it has to refresh?
 
is viewstate enabled for that control?

John O'Donnell said:
in my page load i use this
if{!this.ispostback)
{
populate listbox etc
}

however when i click the button this listbox blanks out and i do not get a
value back.

As i load the listbox using the page_load surely it has to refresh?
 
yes viewstate is enabled

as said...if i load items into the listbox control through the designer
rather than code it all works. It seems that loading items into the listbox
on the page_load causes a problem determining what was selected
 
forget it i goofed up

I had viewstate enabled on all controls but not the page itself.....
damm this has wasted a lot of time

oh well thanks for help!
 
Back
Top