473,396 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

listbox.selectedvalue does not return anything

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

Nov 18 '05 #1
5 5897
It sounds like your listbox is being re-populated on each postback
A
"John O'Donnell" <cs**************@nospam-hotmail.com-nospam> wrote in
message news:ur**************@tk2msftngp13.phx.gbl...
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!!


Nov 18 '05 #2
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?

"Andrew de la Harpe" <an*********@hotmail.com> wrote in message
news:Op**************@TK2MSFTNGP12.phx.gbl...
It sounds like your listbox is being re-populated on each postback
A
"John O'Donnell" <cs**************@nospam-hotmail.com-nospam> wrote in
message news:ur**************@tk2msftngp13.phx.gbl...
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!!



Nov 18 '05 #3
is viewstate enabled for that control?

"John O'Donnell" <cs**************@nospam-hotmail.com-nospam> wrote in
message news:%2******************@TK2MSFTNGP09.phx.gbl...
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?

"Andrew de la Harpe" <an*********@hotmail.com> wrote in message
news:Op**************@TK2MSFTNGP12.phx.gbl...
It sounds like your listbox is being re-populated on each postback
A
"John O'Donnell" <cs**************@nospam-hotmail.com-nospam> wrote in
message news:ur**************@tk2msftngp13.phx.gbl...
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!!




Nov 18 '05 #4
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


"Andrew de la Harpe" <an*********@hotmail.com> wrote in message
news:eM**************@TK2MSFTNGP09.phx.gbl...
is viewstate enabled for that control?

"John O'Donnell" <cs**************@nospam-hotmail.com-nospam> wrote in
message news:%2******************@TK2MSFTNGP09.phx.gbl...
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?

"Andrew de la Harpe" <an*********@hotmail.com> wrote in message
news:Op**************@TK2MSFTNGP12.phx.gbl...
It sounds like your listbox is being re-populated on each postback
A
"John O'Donnell" <cs**************@nospam-hotmail.com-nospam> wrote in
message news:ur**************@tk2msftngp13.phx.gbl...
> 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!!
>
>
>
>
>



Nov 18 '05 #5
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!

"Andrew de la Harpe" <an*********@hotmail.com> wrote in message
news:eM**************@TK2MSFTNGP09.phx.gbl...
is viewstate enabled for that control?

"John O'Donnell" <cs**************@nospam-hotmail.com-nospam> wrote in
message news:%2******************@TK2MSFTNGP09.phx.gbl...
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?

"Andrew de la Harpe" <an*********@hotmail.com> wrote in message
news:Op**************@TK2MSFTNGP12.phx.gbl...
It sounds like your listbox is being re-populated on each postback
A
"John O'Donnell" <cs**************@nospam-hotmail.com-nospam> wrote in
message news:ur**************@tk2msftngp13.phx.gbl...
> 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!!
>
>
>
>
>



Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: jez123456 | last post by:
Hi I have a windows form with 3 ListBoxes. m_listBoxUsers – this displays all users from a database. m_listBoxRoles – this displays available roles that can be assigned to users....
4
by: Moe Sizlak | last post by:
Hi There, I am trying to return the value of a listbox control that is included as a user control, I can return the name of the control but I can't access the integer value of the selected item,...
4
by: dtblankenship | last post by:
Hello everyone, I know this question has been asked many times in the forums, and after spending a few days reading, I am still confused as to the answer. I have a ListBox (lstBox),...
0
by: David J | last post by:
Hi, I am strugling with the propertygrid and a listbox. I am using the universaldropdowneditor from the codeproject (code below). However I am populating the listbox via a datasource. The problem...
5
by: Doug Bell | last post by:
Hi, I thought that this would be a simple exercise but I am struggling to get a result. I need a listbox that will display a list of items from a DataTable, dtUnits. The displayed list comes from...
1
by: A. Spiehler | last post by:
I'm trying to fill a listBox control with string members from an array of objects. I think using data binding is supposed to be the easiest way to do this. I've never used data binding before and...
1
by: fiaolle | last post by:
Hi I Can't get the MSDN's example for Listbox to work.The example is below. I get an error in Listbox's sub ListBox1_SelectedValueChanged at row textBox1.Text = ListBox1.SelectedValue and it...
2
by: =?Utf-8?B?U3RlcGhlbiBSaXRjaGll?= | last post by:
Hi NET1.1 / Winforms I have a listbox that I am binding to a table via the DataSource property. However I want to be able to programmatically select values in this listbox so I am using the...
0
by: =?Utf-8?B?UGF1bA==?= | last post by:
I have a ListBox server control named "lb_dates" with a SelectionMode of "Multiple". The user can select multiple dates from the listbox. I have ObjectDataSource named "ods_rfq" with a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.