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

Real Problem

Okay here is my code. I'm using ASP.Net and SQL Server 2000. When I run this
code the selecteditem.value is 1 the selecteditem.text is ALABAMA. This is
correct. But when I try and get the value once this procedure has run my
selecteditem.value is ALABAMA and the selecteditem.text is ALABAMA. It's not
keeping the selecteditem.value after I change the combobox selection.

Thanks.

Big E

Dim Portal As String
Dim dsState As DataSet
Dim cnPortal As SqlConnection
Dim daState As SqlDataAdapter
Dim dtState As DataTable = New DataTable
Portal = ConfigurationSettings.AppSettings("Portal.Connecti onString")
dsState = New DataSet
cnPortal = New SqlConnection(Portal)
daState = New SqlDataAdapter("SELECT * FROM tlkpState", cnPortal)
daState.Fill(dsState, "tlkpState")
dtState = dsState.Tables("tlkpState")
Dim i As Integer
For i = 0 To dtState.Rows.Count - 1
cboStateCompany.Items.Add(dtState.Rows(i)("StateCo de"))

cboStateCompany.SelectedItem.Value = (dtState.Rows(i)("StateId"))

cboStateCompany.SelectedItem.Text = (dtState.Rows(i)("StateCode"))

Next

cnPortal.Close()
cnPortal = Nothing
Nov 18 '05 #1
3 1022
check your binding, it looks like you are rebinding with JUST the state
passed to the DDL, not the ID & State.

--
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:%2****************@TK2MSFTNGP10.phx.gbl...
Okay here is my code. I'm using ASP.Net and SQL Server 2000. When I run this code the selecteditem.value is 1 the selecteditem.text is ALABAMA. This is
correct. But when I try and get the value once this procedure has run my
selecteditem.value is ALABAMA and the selecteditem.text is ALABAMA. It's not keeping the selecteditem.value after I change the combobox selection.

Thanks.

Big E

Dim Portal As String
Dim dsState As DataSet
Dim cnPortal As SqlConnection
Dim daState As SqlDataAdapter
Dim dtState As DataTable = New DataTable
Portal = ConfigurationSettings.AppSettings("Portal.Connecti onString")
dsState = New DataSet
cnPortal = New SqlConnection(Portal)
daState = New SqlDataAdapter("SELECT * FROM tlkpState", cnPortal)
daState.Fill(dsState, "tlkpState")
dtState = dsState.Tables("tlkpState")
Dim i As Integer
For i = 0 To dtState.Rows.Count - 1
cboStateCompany.Items.Add(dtState.Rows(i)("StateCo de"))

cboStateCompany.SelectedItem.Value = (dtState.Rows(i)("StateId"))

cboStateCompany.SelectedItem.Text = (dtState.Rows(i)("StateCode"))

Next

cnPortal.Close()
cnPortal = Nothing

Nov 18 '05 #2
I'm not positive why that's not working, however, you might want to consider
looking into binding your datatable to the combobox instead of adding each
item individually, it's easier, and avoids user error:

Dim Portal As String
Dim dsState As DataSet
Dim cnPortal As SqlConnection
Dim daState As SqlDataAdapter
Dim dtState As DataTable = New DataTable
Portal = ConfigurationSettings.AppSettings("Portal.Connecti onString")
dsState = New DataSet
cnPortal = New SqlConnection(Portal)
daState = New SqlDataAdapter("SELECT * FROM tlkpState", cnPortal)
daState.Fill(dsState, "tlkpState")
dtState = dsState.Tables("tlkpState")

cboStateCompany.DataSource = dtState
cboState.DataValueField= "StateId"
cboState.DataTextField = "StateCode"
cboStateCompany.DataBind()

cnPortal.Close()
scnPortal = Nothing

see if that fixes anything for you...
(also, if my syntax is incorrect, sorry, I'm a C# programmer... VB.Net is
not my forte)

HTH,
-Cliff
"Big E" <no****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Okay here is my code. I'm using ASP.Net and SQL Server 2000. When I run this code the selecteditem.value is 1 the selecteditem.text is ALABAMA. This is
correct. But when I try and get the value once this procedure has run my
selecteditem.value is ALABAMA and the selecteditem.text is ALABAMA. It's not keeping the selecteditem.value after I change the combobox selection.

Thanks.

Big E

Dim Portal As String
Dim dsState As DataSet
Dim cnPortal As SqlConnection
Dim daState As SqlDataAdapter
Dim dtState As DataTable = New DataTable
Portal = ConfigurationSettings.AppSettings("Portal.Connecti onString")
dsState = New DataSet
cnPortal = New SqlConnection(Portal)
daState = New SqlDataAdapter("SELECT * FROM tlkpState", cnPortal)
daState.Fill(dsState, "tlkpState")
dtState = dsState.Tables("tlkpState")
Dim i As Integer
For i = 0 To dtState.Rows.Count - 1
cboStateCompany.Items.Add(dtState.Rows(i)("StateCo de"))

cboStateCompany.SelectedItem.Value = (dtState.Rows(i)("StateId"))

cboStateCompany.SelectedItem.Text = (dtState.Rows(i)("StateCode"))

Next

cnPortal.Close()
cnPortal = Nothing

Nov 18 '05 #3
Thanks Cliff it works now.
"Cliff Harris" <he***@myrealbox.com> wrote in message
news:u7**************@TK2MSFTNGP11.phx.gbl...
I'm not positive why that's not working, however, you might want to consider looking into binding your datatable to the combobox instead of adding each
item individually, it's easier, and avoids user error:

Dim Portal As String
Dim dsState As DataSet
Dim cnPortal As SqlConnection
Dim daState As SqlDataAdapter
Dim dtState As DataTable = New DataTable
Portal = ConfigurationSettings.AppSettings("Portal.Connecti onString")
dsState = New DataSet
cnPortal = New SqlConnection(Portal)
daState = New SqlDataAdapter("SELECT * FROM tlkpState", cnPortal)
daState.Fill(dsState, "tlkpState")
dtState = dsState.Tables("tlkpState")

cboStateCompany.DataSource = dtState
cboState.DataValueField= "StateId"
cboState.DataTextField = "StateCode"
cboStateCompany.DataBind()

cnPortal.Close()
scnPortal = Nothing

see if that fixes anything for you...
(also, if my syntax is incorrect, sorry, I'm a C# programmer... VB.Net is
not my forte)

HTH,
-Cliff
"Big E" <no****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Okay here is my code. I'm using ASP.Net and SQL Server 2000. When I run

this
code the selecteditem.value is 1 the selecteditem.text is ALABAMA. This is correct. But when I try and get the value once this procedure has run my
selecteditem.value is ALABAMA and the selecteditem.text is ALABAMA. It's

not
keeping the selecteditem.value after I change the combobox selection.

Thanks.

Big E

Dim Portal As String
Dim dsState As DataSet
Dim cnPortal As SqlConnection
Dim daState As SqlDataAdapter
Dim dtState As DataTable = New DataTable
Portal = ConfigurationSettings.AppSettings("Portal.Connecti onString")
dsState = New DataSet
cnPortal = New SqlConnection(Portal)
daState = New SqlDataAdapter("SELECT * FROM tlkpState", cnPortal)
daState.Fill(dsState, "tlkpState")
dtState = dsState.Tables("tlkpState")
Dim i As Integer
For i = 0 To dtState.Rows.Count - 1
cboStateCompany.Items.Add(dtState.Rows(i)("StateCo de"))

cboStateCompany.SelectedItem.Value = (dtState.Rows(i)("StateId"))

cboStateCompany.SelectedItem.Text = (dtState.Rows(i)("StateCode"))

Next

cnPortal.Close()
cnPortal = Nothing


Nov 18 '05 #4

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

Similar topics

18
by: Ken | last post by:
Hi. Can anyone refer me to any articles about the compatibility between c++ polymorphism and real-time programming? I'm currently on a real-time c++ project, and we're having a discussion...
4
by: Aaron W. West | last post by:
Timings... sometimes there are almost too many ways to do the same thing. The only significant findings I see from all the below timings is: 1) Integer math is generally fastest, naturally....
3
by: Gérard Talbot | last post by:
Hello all, When webfonts are used for purely cosmetic/ornemental reasons and on a large scale, I don't agree. When webfonts are used because Unicode support among browsers for a particular...
12
by: Russ | last post by:
I'm interested in setting up a web page where live data can be displayed in real-time on the web page. For example: I would like to display a (nice looking) graph of some data value versus time...
10
by: Pavils Jurjans | last post by:
Hallo, It is know issue that due to the fact that computer has to store the real numbers in limited set of bytes, thus causing a minor imprecision from the decimal value that likely was stored....
17
by: David Scemama | last post by:
Hi, I'm writing a program using VB.NET that needs to communicate with a DOS Pascal program than cannot be modified. The communication channel is through some file databases, and I have a huge...
30
by: Raymond Hettinger | last post by:
Proposal -------- I am gathering data to evaluate a request for an alternate version of itertools.izip() with a None fill-in feature like that for the built-in map() function: >>> map(None,...
12
by: Raymond Hettinger | last post by:
I am evaluating a request for an alternate version of itertools.izip() that has a None fill-in feature like the built-in map function: >>> map(None, 'abc', '12345') # demonstrate map's None...
14
by: dE|_ | last post by:
For months I have been happily using a downloaded JS file and inline script to embed and control the parameters of SWF files which I use as mp3 players with actionscript. The last so.addParam...
4
by: The Doctor | last post by:
Hey people, I have two applications: the server, which creates a server socket, waits for a real-time signal, and if it receives one, it creates a client socket. The client, which will...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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.