473,396 Members | 1,683 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.

combobox.SelectedItem woes?

JP
I have C# ASP.NET VS 2005 combo box set to perform an auto post back when
the user changes the index

protected void dropSSNEdit_SelectedIndexChanged(object sender, EventArgs
e)
{
txtSSN.Text = dropSSN.SelectedItem.ToString();
}
The dropdown control contains SSNs for the ITEMS attribute, the VALUES for
these items are the database IDs that point to that specific record. This way
if the user changes the SSN, it uses the ID in the VALUE attribute to know
what record in SQL to go update.

As you can see, I want to set a text box to the SelectedItem (TEXT) that the
user choose. The problem is that according to the MS Intellisense
..SelectedItem "Gets the selected item with the LOWEST index in the control.

No matter what SSN I select from the dropdown, the textbox is always set to
the first item in the list. This is not what I want. I want the textbox set
to the item of the CURRENT select index, not the LOWEST index

Again I can’t use .SelectedValue b/c it contains the SQL record ID and not
the value the user is supposed to edit.

But if you read MSDN for Frame work 2.0 it says: "Gets or sets currently
selected item in the ComboBox". Which is what I want.
Someone please help. I cant see a way in C# where I could say
dropSSN.SelectedIndex(dropSSN.SelectItem). I know I cant be the only one
that’s noticed this issue. If SelectedItem always gets the LOWEST then there
is no difference between that and saying dropSSN.SelectedIndex = 0.

Oct 19 '06 #1
1 1782
I had an issue where i was loading the values on the page load. Since it is
a postback, the checkbox was getting reset in the PageLoad event. So i added
If(!IsPostBack)
{
}

to my PageLoad function. If this isn't the case, you could try using the
SelectedValue, instead of the SelectedIndex. But it seems like it is getting
reset somehow.

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...neral/200610/1

Oct 27 '06 #2

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

Similar topics

8
by: Supa Hoopsa | last post by:
I have a databound combobox within a datagrid. I have set the DisplayMember and ValueMember. BUT, how do I capture the Value (SelectedValue) when the user changes the selection?
3
by: Bill C. | last post by:
Hello, I know this has been discussed a lot already because I've been searching around for information the last few weeks. I'm trying to implement a DataGridComboBoxColumn class. I've found...
4
by: Beeeeeeeeeeeeves | last post by:
I have an ownerdrawn combo box which I am drawing with an image and some text, this is all working beautifully apart from the difference in the Brush I have to draw the background and the text with...
2
by: Vern | last post by:
I created a table in a dataset that contains multiple columns. I attached a combo box to that table. Now I'm doing something wrong with trying to retrieve the value of the third column of the...
0
by: Doug | last post by:
This is a repost of an item that I still cannot resolve. I have 3 combo boxes. The first leads to the second to the third. When I have selected a value in the second box, the third box shows...
19
by: active | last post by:
I'm using a ComboBox to display objects of a class I've defined, say CQQ. Works great except somehow I occasionally set an Item to a String object instead of an object of type CQQ. It looks...
5
by: Crazy Cat | last post by:
Hi all, I have combobox that is bound to a custom object collection thusly Dim collection As List(Of StructureType) = StructureType.FindStructureTypes(SharedObjects.StructureTypes,...
7
by: JTC^..^ | last post by:
When i attempt to bind to the "Text" and "Value" property of a combobox on a windows form the value is reset when I leave the combobox. The comboboxes contain the correct Text and Values. I know...
0
by: Germaris | last post by:
Hi there! On my form I have two ComboBoxes. The first displays a list of countries. The second one, if the country selected in the first ask for, displays a list of states, provinces or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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,...

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.