G
Guest
Hello,
I have a dropdown list on a user control and the AutoPostBack property is
set to True. I want to use the SelectedIndexChanged event to populate some
text boxes based on what the user chose in the dropdown list.
However, the SelectedIndexChanged event doesn't fire. In the immediate
window it appears that the index is not changing when I select a different
option in the list.
After wrestling with this for a couple hours, I think it has to do with the
fact that I am loading the list options from the database:
sql = "SELECT Code, Description FROM luApptType"
ds = clsDB.GetDataSet(sql)
With Me.lstApptType
.DataSource = ds
.DataTextField = "Description"
.DataValueField = "Code"
.DataBind()
.Items().Insert(0, New ListItem(""))
End With
The code above is contained in a LoadLists function that is called in the
first Page Load:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
LoadLists()
End If
End Sub
When I try this with a second dropdown where the options are hard-coded, the
SelectedIndexChanged event fires as expected. No problems.
Can you tell me why it's not working with the first dropdown where the
options are loaded at runtime?
Thanks -- I'm at my wit's end!
I have a dropdown list on a user control and the AutoPostBack property is
set to True. I want to use the SelectedIndexChanged event to populate some
text boxes based on what the user chose in the dropdown list.
However, the SelectedIndexChanged event doesn't fire. In the immediate
window it appears that the index is not changing when I select a different
option in the list.
After wrestling with this for a couple hours, I think it has to do with the
fact that I am loading the list options from the database:
sql = "SELECT Code, Description FROM luApptType"
ds = clsDB.GetDataSet(sql)
With Me.lstApptType
.DataSource = ds
.DataTextField = "Description"
.DataValueField = "Code"
.DataBind()
.Items().Insert(0, New ListItem(""))
End With
The code above is contained in a LoadLists function that is called in the
first Page Load:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
LoadLists()
End If
End Sub
When I try this with a second dropdown where the options are hard-coded, the
SelectedIndexChanged event fires as expected. No problems.
Can you tell me why it's not working with the first dropdown where the
options are loaded at runtime?
Thanks -- I'm at my wit's end!