listbox.selectedvalue does not return anything

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!!
 
J

John O'Donnell

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?
 
A

Andrew de la Harpe

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?
 
J

John O'Donnell

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
 
J

John O'Donnell

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!
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top