473,761 Members | 9,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DropDownList event not firing as expected

Hi,

Apologies, but I appear to be having a senior moment...

I have a standard DropDownList webcontrol with a SelectedIndexCh anged event,
as follows:

<asp:TableCel l ColumnSpan=4 VerticalAlign=M iddle>
Select your delivery location:
<asp:DropDownLi st ID="cmbShipping " Runat="server"
OnSelectedIndex Changed="cmbShi pping_SelectedI ndexChanged"
AutoPostBack="t rue">
<asp:ListItem Value="0">&nbsp ;</asp:ListItem>
<asp:ListItem Value="1">Unite d Kingdom</asp:ListItem>
<asp:ListItem Value="2">Europ ean Union</asp:ListItem>
<asp:ListItem Value="3">Rest of world</asp:ListItem>
</asp:DropDownLis t>
</asp:TableCell>
And the code-behind is as follows:

protected DropDownList cmbShipping;

private void Page_Load(objec t sender, System.EventArg s e)
{
if(!Page.IsPost Back)
{
BindData();
}
}

public void cmbShipping_Sel ectedIndexChang ed(object sender, EventArgs e)
{
try
{
BindData();
}
catch (Exception ex)
{
CApplication.Gl obalExceptionHa ndler(ex);
}
}

private void BindData()
{
// code to do the data binding goes here...
}
Problem is that the cmbShipping_Sel ectedIndexChang ed() event only fires if
the SelectedValue of the DropDownList is greater than zero i.e. if I change
it from 0 to any other value, the event fires, but if I change it back to
zero the event doesn't fire...No errors are raised and, if I place a
breakpoint on the BindData(); line within the event code, it doesn't even
appear to jump into it...

I'm clearly missing something totally obvious...

Any assitance gratefully received.

Mark
Nov 19 '05 #1
3 1526
"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:uh******** ******@TK2MSFTN GP15.phx.gbl...
Problem is that the cmbShipping_Sel ectedIndexChang ed() event only fires if
the SelectedValue of the DropDownList is greater than zero i.e. if I
change it from 0 to any other value, the event fires, but if I change it
back to zero the event doesn't fire...No errors are raised and, if I place
a breakpoint on the BindData(); line within the event code, it doesn't
even appear to jump into it...


Not only that - the event fires even if other controls on the page trigger
the PostBack...

Anyone got any thoughts on this...?
Nov 19 '05 #2
Do you have any sort of validations on your page?
Patrick

"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:eC******** ******@TK2MSFTN GP14.phx.gbl...
"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:uh******** ******@TK2MSFTN GP15.phx.gbl...
Problem is that the cmbShipping_Sel ectedIndexChang ed() event only fires if the SelectedValue of the DropDownList is greater than zero i.e. if I
change it from 0 to any other value, the event fires, but if I change it
back to zero the event doesn't fire...No errors are raised and, if I place a breakpoint on the BindData(); line within the event code, it doesn't
even appear to jump into it...


Not only that - the event fires even if other controls on the page trigger
the PostBack...

Anyone got any thoughts on this...?

Nov 19 '05 #3
"Patirck Ige" <na********@hot mail.com> wrote in message
news:eF******** ******@TK2MSFTN GP09.phx.gbl...
Do you have any sort of validations on your page?


There is a form with a submit button which checks that the DropDownList in
question doesn't have a selectedIndex of 0 before submitting it, as follows:

<script>

function submitPayPal()
{
if(document.frm Default.cmbShip ping.selectedIn dex == 0)
{
alert('Please select a delivery
location');docu ment.frmDefault .cmbShipping.fo cus();
return false;
}
}

</script>

And the corresponding HTML is:

<input type="submit" value="Proceed to checkout" onclick="return
submitPayPal(); ">
Nov 19 '05 #4

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

Similar topics

2
3049
by: Shiju Poyilil | last post by:
Hi ! I have a requirement wherein i am binding a datalist which contains a label (Caption for the field) and some literal hidden fields and a dropdown list. When I am binding to the datalist.. only the labels (caption) and the invisible literal controls are binded.. Now based on the invisible literal control values I get the information from DB to bind it with each dropdown list (I am doing this in the item databound event) Also based on...
3
2303
by: Lew Barnesson | last post by:
Hi All, I have looked and looked for an answer to the following problem (without success), and would be very grateful for a solution. The problem: The SelectedIndexChanged event code of an Asp.Net DropDownList changes text in an adjacent TextBox by either concatenating SelectedItem.Text (from the DropDownList) if it is not in the TextBox, or removing it if it is in the TextBox. This generally works very well.
5
4396
by: bryanp10 | last post by:
I have a page that is almost entirely dynamically created. Textboxes and checkbox are working fine, firing events, and persistent their state. DropDownList is giving me a major headache. All my controls are created in CreateChildControls() for my custom control. Here's a snippet of code: DropDownList dd = new DropDownList(); dd.ID = "DropDown1"; if( !Page.IsPostBack )
1
4439
by: Paul L | last post by:
Hi, I have an issue with the OnSelectedIndexChanged event not firing for a DropDownList control which is in the ItemTemplate of a DataList. I have made an exact copy of the DropDownList control, and placed it outside of the DataList and it fires the event just fine. So it's definitely to do with it being in a template. I've managed to reproduce the issue on a small test app, the code and html is below:
4
1946
by: David | last post by:
Hi all, I am doing this in a web page... I have a dropdownlist that autopostback. This sets me a filter criteria for items to display in a datalist. In the datalist, I have edit capabilities, which opens a text box. When I click Update for the datalist (edit), then for some reason, the
2
3336
by: AdrEsqu | last post by:
I am trying to use AutoPostback to retrieve the value that was selected in my dropdownlist. The event is not firing for the dropdownlist because the datagrid is being built after the Lifecycle of the Firing Events. So in order to capture my selected value I need to capture it in the OnInit when the autopostback fires, but I don't know how I can do this. Since the Page Lifecycle fires events before my datagrid gets built then I can...
2
3305
by: jnoody | last post by:
The problem I am having is with the SelectedIndexChanged event not always firing or the SelectedIndex property not being correct when the event does fire. The code is below, but here are some details first. The DropDownList is actually a custom control called DropDownListWithCommandEvent that inherits from DropDownList. The reason I have created this is to create a DropDownList that will bubble a Command event to the containing...
7
12065
by: Damien | last post by:
Hi guys, I'm trying to learn ASP.NET and got a problem with DroDownList... SelectedIndexChanged doesn't fire. Maybe you'll be able to suggest something. I think it may be connected with the fact I fill this list dynamically. I use the following code:
1
1570
by: =?iso-8859-1?B?R2VhcvNpZA==?= | last post by:
Hi, Wierd problem. Using ASP.NET 2.0. Have a DropDownList - <asp:DropDownList ID="DropDownListMake" runat="server" CssClass="selectComparison" AutoPostBack="True" OnSelectedIndexChanged="DropDownListMake_SelectedIndexChanged" />
0
9554
marktang
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...
0
9376
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
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, 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...
0
9988
jinu1996
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...
1
9923
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,...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3911
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
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...

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.