Tengo una lista desplegable sencilla (FFG) ...valor seleccionado no cambia en asp: DropDownList
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="true" BackColor="LightSteelBlue" Font-Size="X-Small"
OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged1" Style="z-index: 102; left: 37px; position: absolute; top: 85px" Width="331px"
</asp:DropDownList>
cual enlazar datos a usind caso onpageload ...
DropDownList2.DataSource = td.DataSet
DropDownList2.DataSource = td
DropDownList2.DataTextField = td.Columns("Name").ColumnName.ToString
DropDownList2.DataValueField = td.Columns("VendorCode").ColumnName.ToString
DropDownList2.DataBind()
y onleselectedindexchaged
un evento en el que intento es posible recuperar el valor nuevo como esto ...
Protected Sub DropDownList2_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.TextChanged
Dim url As String = "sp_menu.aspx?sp=" & DropDownList2.SelectedValue
Session.Remove("sp")
Session("sp") = DropDownList2.SelectedValue
Session("spnm") = DropDownList2.SelectedItem.Text & " (" & DropDownList2.Text & ")"
Response.Redirect(url)
End Sub
Pero siempre trae la primera Valu e no importa cuál se haga clic en la lista desplegable. Por favor ayuda!
favor formatear su código! –
Si ese ejemplo es correcto, especificó que el controlador de eventos sea DropDownList2_SelectedIndexChanged1 pero su código esté en DropDownList2_TextChanged. Se llama al manejador incorrecto o solo a un error tipográfico en la publicación? – Trotts
El textchaged era una alternativa que estaba intentando, mi código está en DropDownList2_SelectedIndexChanged1 –