473,756 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

listbox.selecte dvalue 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.selecte dvalue etc.

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

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

any ideas?

thanks!!

Nov 18 '05 #1
5 5916
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******** ******@tk2msftn gp13.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.selecte dvalue etc.

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

In fact if i set the listbox.selecte ditem=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.ispost back)
{
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*********@ho tmail.com> wrote in message
news:Op******** ******@TK2MSFTN GP12.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******** ******@tk2msftn gp13.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.selecte dvalue etc.

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

In fact if i set the listbox.selecte ditem=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******** **********@TK2M SFTNGP09.phx.gb l...
in my page load i use this
if{!this.ispost back)
{
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*********@ho tmail.com> wrote in message
news:Op******** ******@TK2MSFTN GP12.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******** ******@tk2msftn gp13.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.selecte dvalue etc.

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

In fact if i set the listbox.selecte ditem=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*********@ho tmail.com> wrote in message
news:eM******** ******@TK2MSFTN GP09.phx.gbl...
is viewstate enabled for that control?

"John O'Donnell" <cs************ **@nospam-hotmail.com-nospam> wrote in
message news:%2******** **********@TK2M SFTNGP09.phx.gb l...
in my page load i use this
if{!this.ispost back)
{
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*********@ho tmail.com> wrote in message
news:Op******** ******@TK2MSFTN GP12.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******** ******@tk2msftn gp13.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.selecte dvalue etc.
>
> somehow the server side is unaware that i have selected an item.
>
> In fact if i set the listbox.selecte ditem=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*********@ho tmail.com> wrote in message
news:eM******** ******@TK2MSFTN GP09.phx.gbl...
is viewstate enabled for that control?

"John O'Donnell" <cs************ **@nospam-hotmail.com-nospam> wrote in
message news:%2******** **********@TK2M SFTNGP09.phx.gb l...
in my page load i use this
if{!this.ispost back)
{
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*********@ho tmail.com> wrote in message
news:Op******** ******@TK2MSFTN GP12.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******** ******@tk2msftn gp13.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.selecte dvalue etc.
>
> somehow the server side is unaware that i have selected an item.
>
> In fact if i set the listbox.selecte ditem=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
1529
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. m_listBoxUserRoles – this displays the role assigned to a selected user. When I select a user in m_listBoxUsers and a role in m_listBoxRoles, I can assign the selected role to the user with the following code. The role is then added to m_listBoxUserRoles...
4
2460
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, what do I need to do in order to return the "option value" of the control? Moe !--- returned value of the control
4
4210
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), SqlConnection (sqlConnection), SqlDataAdapter (daLookupData), SqlDataAdapter (daData), DataSet (dsLookupData), and DataSet (dsData), all created via the IDE during design-time. Here is the design of my simple tables: (An example since I can't post my...
0
2661
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 I am having is that when I have a value in the propertygird and edit that, I want the listbox to have the selectvalue equal to the value that is being edited. Just to make it clearer: PropgridVal = Germany Datasource=
5
2298
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 Column . Selecting an item in this list needs to return a value from Column . Data in dtUnits is UnitsProdDescn UnitsConvn Carton 3.2
1
2779
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 am having trouble getting it to do anything. The relevant code is below, followed by a better explanation of what I'm trying to do. // pseudocode start public delegate string StepMethod();
1
3232
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 happens after the line ListBox1.ValueMember = "ShortName" is run. The error says Cast from type 'USState' to type 'String' is not valid. I don't know why the code doesn't work, can anyone please explain that for me.
2
5544
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 code below... With lstJobTypes .DataSource = BusinessRules.Common.JobTypes.All(True)
0
2140
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 ControlParameter that has a ControlID that points to "lb_dates". The PropertyName of the ControlParameter is "SelectedValue". The user selects two dates from the ListBox. I am trying to pass BOTH selected values of the ListBox to a SelectMethod of
0
9456
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10034
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9872
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9843
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.