Tôi có một DropDownList đơn giản (ffg) ...giá trị được chọn không thay đổi trong 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>
mà tôi ràng buộc dữ liệu để usind sự kiện onpageload ...
DropDownList2.DataSource = td.DataSet
DropDownList2.DataSource = td
DropDownList2.DataTextField = td.Columns("Name").ColumnName.ToString
DropDownList2.DataValueField = td.Columns("VendorCode").ColumnName.ToString
DropDownList2.DataBind()
và một sự kiện onleselectedindexchaged
nơi tôi cố gắng truy xuất giá trị mới như thế này ...
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
Nhưng nó luôn luôn mang lại valu đầu tiên e cho dù ai được nhấp vào danh sách thả xuống. Xin vui lòng giúp đỡ!
Vui lòng định dạng mã của bạn! –
Nếu ví dụ đó đúng, bạn đã chỉ định trình xử lý sự kiện là DropDownList2_SelectedIndexChanged1 nhưng mã của bạn nằm trong DropDownList2_TextChanged. Trình xử lý sai được gọi hoặc chỉ là lỗi đánh máy trong bài đăng? – Trotts
Các textchaged là một thay thế tôi đã cố gắng, mã của tôi là trong DropDownList2_SelectedIndexChanged1 –