DropDownList SelectedItem Problem

I

Ivan

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?
 
I

Ivan

The Problem is that allways I get 1, that is the first item selected, no
matter wich exactly is selected
 
R

R Warford

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)
 
R

R Warford

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top