[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

SelectedItem always -1 in dropdownlist

=?iso-8859-1?B?UmFt824=?=

1/18/2003 9:39:00 AM

Hi all,

I have to set the property SelectedIndex of a=20
DropDownList, that is part of a form, to a predefined=20
value with the net command:

<tr>
<td><asp:Label id=3D"EtiquetaLocalidad" runat=3D"server">=20
</asp:Label></td>
<td><asp:DropDownList id=3D"DropListLocalidad"=20
runat=3D"server"> </asp:DropDownList></td>
</tr>
<%
DropListLocalidad.SelectedIndex =3D 1
%>
...

Later, when the user press the Button "Submit" the code=20
checks which value was finally selected (the user can=20
change the selected value of the dropdownlist) to forward=20
it. The code I use is:

If DropListLocalidad.SelectedIndex > -1 then
If Dir_Respuesta <> "" Then Dir_Respuesta =3D=20
Dir_Respuesta & "&"
Dir_Respuesta =3D Dir_Respuesta & "Loc=3D" &=20
DropListLocalidad.SelectedItem.Text
End If

I can set the SelectedIndex, but I always read the value -
1 after pressing the button. It's not important if I=20
later select a new option or not.

What's the problem? I've spent more than a week getting=20
around it but I can't solve it.

Thanks in advance and Regards, Ram=F3n.