Hello,
I have a dropdown list on a user control and the AutoPostBack property is
set to True. I want to use the SelectedIndexCh anged event to populate some
text boxes based on what the user chose in the dropdown list.
However, the SelectedIndexCh anged 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.GetDataSe t(sql)
With Me.lstApptType
.DataSource = ds
.DataTextField = "Descriptio n"
.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.EventArg s) 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
SelectedIndexCh anged 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! 1 5740
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 SelectedIndexCh anged event to populate some text boxes based on what the user chose in the dropdown list.
However, the SelectedIndexCh anged 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.GetDataSe t(sql) With Me.lstApptType .DataSource = ds .DataTextField = "Descriptio n" .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.EventArg s) 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 SelectedIndexCh anged 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! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 are bound. The items are loaded just fine into
the dropdown lists at the time of page load. When I try to select an item
from the dropdown list, it always ends up selecting the first item.
|
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. However, if you ever
(even after you have selected other options previously) select the first
option in the dropdown, the AutoPostBack fires(the page reloads), but the
event does not. This is the only element on my page and ViewState is enabled...
|
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 changed by the
user and then some other control causes the postback, the event
handler still gets called. Is there some way to ignore the event
handler unless the dropdown is the control that caused the postback?
Or is there a way for me to tell which...
|
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.
Let's say you select 1 of the items, and are properly redirected. You press
the back button. I have three servers providing two different
functionalities:
1. After pressing the back button, the item you selected in the dropdown is
still selected.
|
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, it populated the
others accordingly.
In ASP.Net, I was looking for a way to do this without javascript. So, I
made my form and put code in the SelectedIndexChanged event of the dropdown
that populates the next dropdown. Of course to do this,...
| |
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 selects a value, the
codebehind event fires, but if the value is changed via javascript, it
doesnt. I tried __doPostBack, but it posts entire form back and fires
all the validation check.
How can I achieve firing of server side event via javascript?...
|
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 set to...it is set to
false.
Can someone show me what I am doing wrong and tell me the correct way? Thank
you.
In the page load event, I am doing the following:
|
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 respoand at all ... what else should I
set ?
Travis Tan
|
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)
{
// some other code
DropDownList ddlGroups = new DropDownList();
ddlGroups.SelectedIndexChanged += new
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |