469,572 Members | 1,210 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

DropDownList SelectedItem Problem

Hi,
I have a problem with a page which has about 50 web controls , 12 of the are
DropDownList.
Also, I have a "Continue" button, and on the server code an event sub
btnContinue_Click, where I process the input data.
There is a code like :

Dim MyVariable As Integer
Dim AnOtherVariable As Integer
MyVariable = DropDownList1.SelectedItem.Value
AnOtherVariable = DropDownList2.SelectedItem.Value

Can anyone help?
Nov 18 '05 #1
4 1571
The Problem is that allways I get 1, that is the first item selected, no
matter wich exactly is selected
"Ivan" <iz*****@hotmail.com> wrote in message
news:er*************@TK2MSFTNGP09.phx.gbl...
Hi,
I have a problem with a page which has about 50 web controls , 12 of the are DropDownList.
Also, I have a "Continue" button, and on the server code an event sub
btnContinue_Click, where I process the input data.
There is a code like :

Dim MyVariable As Integer
Dim AnOtherVariable As Integer
MyVariable = DropDownList1.SelectedItem.Value
AnOtherVariable = DropDownList2.SelectedItem.Value

Can anyone help?

Nov 18 '05 #2
You don't state what the problem is, but judging from the
code sample you provided, I'd say you need to convert the
selected value to an integer.

You'll need something like the following:

MyVar = Integer.Parse(DropDownList1.SelectedItem.Value)
-----Original Message-----
Hi,
I have a problem with a page which has about 50 web controls , 12 of the areDropDownList.
Also, I have a "Continue" button, and on the server code an event subbtnContinue_Click, where I process the input data.
There is a code like :

Dim MyVariable As Integer
Dim AnOtherVariable As Integer
MyVariable = DropDownList1.SelectedItem.Value
AnOtherVariable = DropDownList2.SelectedItem.Value

Can anyone help?
.

Nov 18 '05 #3
Are you populating the drop down lists dynamically? I've
had similar problems when I accidentally put the
population code in the PageLoad event and did not protect
it with a test for IsPostBack.

-Roger
-----Original Message-----
The Problem is that allways I get 1, that is the first item selected, nomatter wich exactly is selected
"Ivan" <iz*****@hotmail.com> wrote in message
news:er*************@TK2MSFTNGP09.phx.gbl...
Hi,
I have a problem with a page which has about 50 web controls , 12 of the
are
DropDownList.
Also, I have a "Continue" button, and on the server

code an event sub btnContinue_Click, where I process the input data.
There is a code like :

Dim MyVariable As Integer
Dim AnOtherVariable As Integer
MyVariable = DropDownList1.SelectedItem.Value
AnOtherVariable = DropDownList2.SelectedItem.Value

Can anyone help?

.

Nov 18 '05 #4

It works now :)
IsPostBack was the problem

Thanks

"R Warford" <an*******@discussions.microsoft.com> wrote in message
news:0f****************************@phx.gbl...
Are you populating the drop down lists dynamically? I've
had similar problems when I accidentally put the
population code in the PageLoad event and did not protect
it with a test for IsPostBack.

-Roger
-----Original Message-----
The Problem is that allways I get 1, that is the first

item selected, no
matter wich exactly is selected
"Ivan" <iz*****@hotmail.com> wrote in message
news:er*************@TK2MSFTNGP09.phx.gbl...
Hi,
I have a problem with a page which has about 50 web controls , 12 of the
are
DropDownList.
Also, I have a "Continue" button, and on the server

code an event sub btnContinue_Click, where I process the input data.
There is a code like :

Dim MyVariable As Integer
Dim AnOtherVariable As Integer
MyVariable = DropDownList1.SelectedItem.Value
AnOtherVariable = DropDownList2.SelectedItem.Value

Can anyone help?

.

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Randy Armknecht | last post: by
1 post views Thread by vladp | last post: by
4 posts views Thread by ^MisterJingo^ | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.