473,322 Members | 1,401 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,322 software developers and data experts.

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 SelectedIndexChanged event,
as follows:

<asp:TableCell ColumnSpan=4 VerticalAlign=Middle>
Select your delivery location:
<asp:DropDownList ID="cmbShipping" Runat="server"
OnSelectedIndexChanged="cmbShipping_SelectedIndexC hanged"
AutoPostBack="true">
<asp:ListItem Value="0">&nbsp;</asp:ListItem>
<asp:ListItem Value="1">United Kingdom</asp:ListItem>
<asp:ListItem Value="2">European Union</asp:ListItem>
<asp:ListItem Value="3">Rest of world</asp:ListItem>
</asp:DropDownList>
</asp:TableCell>
And the code-behind is as follows:

protected DropDownList cmbShipping;

private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
BindData();
}
}

public void cmbShipping_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
BindData();
}
catch (Exception ex)
{
CApplication.GlobalExceptionHandler(ex);
}
}

private void BindData()
{
// code to do the data binding goes here...
}
Problem is that the cmbShipping_SelectedIndexChanged() 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 1505
"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:uh**************@TK2MSFTNGP15.phx.gbl...
Problem is that the cmbShipping_SelectedIndexChanged() 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**************@TK2MSFTNGP14.phx.gbl...
"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:uh**************@TK2MSFTNGP15.phx.gbl...
Problem is that the cmbShipping_SelectedIndexChanged() 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********@hotmail.com> wrote in message
news:eF**************@TK2MSFTNGP09.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.frmDefault.cmbShipping.selectedIndex == 0)
{
alert('Please select a delivery
location');document.frmDefault.cmbShipping.focus() ;
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
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.....
3
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...
5
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...
1
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,...
4
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...
2
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...
2
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...
7
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...
1
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"...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.