473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Dropdown list - SelectedIndexChanged event doesn't fire

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!

Nov 19 '05 #1
1 5712
Please disregard my earlier post. I had a coworker take a look at it, and on
the first run-through, it magically started working.

"Jack" wrote:
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!

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Vinay | last post by:
Hi All: I'm having a strange problem with the dropdownlist. Here is what is happening: I have a webform on which I have a whole bunch of controls. The form has 2 dropdownlists. The dropdowns...
2
by: hypomite | last post by:
I have an handler for the SelectedIndexChanged event of a dropdown box. I have also set the AutoPostBack option to True. When you select any item besides the first one, the event sucessfully fires....
0
by: john | last post by:
I have a dropdown with a SelectedIndexChanged event handler. I want the event to only get called if the dropdown list was the control that caused the postback. But if the value of the list is...
6
by: Mark | last post by:
I have two dropdown lists. Both have autopostback set to true. In both dropdowns, when you select an item from the list, it redirects to the Value property of the dropdown. Nothing fancy. ...
3
by: Jon | last post by:
I am using cascading dropdowns, where the selection in one determines what fills another. In regular ASP I simply loaded a giant dataset into javascript array and when you clicked on one dropdown,...
1
by: maheshvd | last post by:
Hi all, If I change the selected value of a dropdown server control on client side, is there any way to force the serverside Selectedindexchanged event? (if the user clicks on the dropdown and...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
2
by: Travis | last post by:
Hi , I use C# to create a dropdown list in the web page and I place some code in the SelectedIndexChanged event. But when I click on the list to select certain job to perfom , there is not...
11
by: J055 | last post by:
Hi I have a dropdown control which is constructed in another dropdown control SelectedIndexChanged event protected void ddlParamType_SelectedIndexChanged(object sender, EventArgs e) { //...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.