473,486 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Combobox Id

I'm using VB in ASP.Net with SQL Server 2000.

I have a States Combobox that lists the State. The State has a StateId in
table states. When I do updates to various tables from the form I would like
to update the StateId not the StateName. I've looked at the datamember and
datavalue stuff but don't understand it.

Can anyone point me at a sample or some code they've used.

Thanks.

Big E

Nov 18 '05 #1
4 986
Combo box or DropDownList?
should be
this.DropDownList1.SelectedItem.Value
or
this.DropDownList1.SelectedItem.Text

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Big E" <no****@nospam.com> wrote in message
news:eQ***************@TK2MSFTNGP11.phx.gbl...
I'm using VB in ASP.Net with SQL Server 2000.

I have a States Combobox that lists the State. The State has a StateId in
table states. When I do updates to various tables from the form I would like to update the StateId not the StateName. I've looked at the datamember and
datavalue stuff but don't understand it.

Can anyone point me at a sample or some code they've used.

Thanks.

Big E

Nov 18 '05 #2
Your the best. Curt is the champ. It works.

"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:uT****************@TK2MSFTNGP09.phx.gbl...
Combo box or DropDownList?
should be
this.DropDownList1.SelectedItem.Value
or
this.DropDownList1.SelectedItem.Text

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Big E" <no****@nospam.com> wrote in message
news:eQ***************@TK2MSFTNGP11.phx.gbl...
I'm using VB in ASP.Net with SQL Server 2000.

I have a States Combobox that lists the State. The State has a StateId in table states. When I do updates to various tables from the form I would

like
to update the StateId not the StateName. I've looked at the datamember and datavalue stuff but don't understand it.

Can anyone point me at a sample or some code they've used.

Thanks.

Big E


Nov 18 '05 #3
Actually. When I try and retrieve the contents of the dropdownlist later the
Value has the equivalents of the text. When I loaded it with data in a loop
the value was 1 where the text was Alabama. Now later they both contain
Alabama.

Thanks.

Big E
TextBox1.Text = cboStateCompany.SelectedItem.Value

TextBox2.Text = cboStateCompany.SelectedItem.Text

"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:uT****************@TK2MSFTNGP09.phx.gbl...
Combo box or DropDownList?
should be
this.DropDownList1.SelectedItem.Value
or
this.DropDownList1.SelectedItem.Text

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Big E" <no****@nospam.com> wrote in message
news:eQ***************@TK2MSFTNGP11.phx.gbl...
I'm using VB in ASP.Net with SQL Server 2000.

I have a States Combobox that lists the State. The State has a StateId in table states. When I do updates to various tables from the form I would

like
to update the StateId not the StateName. I've looked at the datamember and datavalue stuff but don't understand it.

Can anyone point me at a sample or some code they've used.

Thanks.

Big E


Nov 18 '05 #4
Hey Big E,
the DataTextField and DataValueField properties of the dropdownlist
are actually pretty simple. In your states table, I am assuming you
have 2 rows. The stateID and the stateName. At design time, you want
to make the DataTextField of your dropdown "stateName", and your
DataValueField "stateID". When the form submits, you can simply look
at the value of the dropdownlist, and it should be the stateID. Hope
this helps!
Nov 18 '05 #5

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

Similar topics

13
2740
by: Mr. B | last post by:
Here's the situation... You've a combobox with Items already added. Say they look like this (or even lines of text): 10-00-232 10-00-256 10-01-006 10-01-213 10-02-200
7
8477
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way...
8
12062
by: Zlatko Matię | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
1
2477
by: anonymous | last post by:
I've been trying to put a them, please help me out. Here's the major parts of my code: public Form1() { DataSet myDataSet = new DataSet("myDataSet"); DataTable testTable = new...
3
6803
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article:...
2
6165
by: Don | last post by:
I've looked high and low for some code that will allow me to have a combobox with a flat borderstyle. I found a few examples, but nothing that was really usable for me. I had the following...
4
4599
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
6
2839
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
1
3353
by: polocar | last post by:
Ciao a tutti, leggendo qua e lą per il forum ho scoperto che non sono l'unico ad avere questo problema. Se si inserisce un controllo ComboBox in un form di C#, non č possibile impostare la sua...
5
5880
by: Rich | last post by:
Hello, I have a search application to search data in tables in a database (3 sql server tables). I populate 2 comboboxes with with data from each table. One combobox will contain unique...
0
7094
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
6964
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
7123
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
7173
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...
1
6839
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
7305
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
5427
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,...
1
4863
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...
0
1378
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 ...

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.