DropDownList SelectedItem Problem

  • Thread starter Thread starter Ivan
  • Start date Start date
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?
 
The Problem is that allways I get 1, that is the first item selected, no
matter wich exactly is selected
 
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)
 
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
 
Back
Top