473,471 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

My DropDownList handler isn't executing.

I have a asp:dropdownlist set to autopostback.

However, my handler doesn't seem to execute (even though there is a
postback).

Here's the DDL:

<asp:dropdownlist id=ddl_districtSelect runat="server" AutoPostBack="True">
(list items)
</asp:dropdownlist>

and the handler:

Private Sub ddl_districtSelect_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ddl_districtSelect.SelectedIndexChanged
response.Write("MONKEY")
End Sub

Any reason why this wouldn't be executing?

-Darrel
Nov 19 '05 #1
12 1508
> However, my handler doesn't seem to execute (even though there is a
postback).


Hmm...I also have another problem. The auto-postback isn't retaining the
selected value. It keeps reverting to the first item.

I don't normally use drop down auto-postbacks, so am I just completely not
'getting' some fundamental concept here?

-Darrel
Nov 19 '05 #2
Are you rebinding the data every time the page loads? This may be your
problem. You only need to bind once.

"darrel" <no*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
However, my handler doesn't seem to execute (even though there is a
postback).


Hmm...I also have another problem. The auto-postback isn't retaining the
selected value. It keeps reverting to the first item.

I don't normally use drop down auto-postbacks, so am I just completely not
'getting' some fundamental concept here?

-Darrel

Nov 19 '05 #3
Are you rebinding the data every time the page loads? This may be your
problem. You only need to bind once.


Nope. no databinding at all. Just a simple option list right in the HTML
itself.

-Darrel
Nov 19 '05 #4
If your ddl is reverting to the first item and not keeping the selected
item from prior to the postback, you are probably calling databind() on
the control on the postback. Here is a general rule of thumb for
getting data, binding to it and the Page_Load event:

In page load, before checking the IsPostBack property, get your data.
Then check if the page is being posted back. If not, call DataBind on
the controls.

Page_Load(<<args>>)
{
// get data.
dataAdapter.Fill(dataTable);

// check for postback.
if (!this.IsPostBack)
{
control.DataBind();
}
}

The exception to this would be if you are using a datareader for your
ddl. Then get the datareader and bind the control only if the page is
NOT a postback.

Page_Load(<<args>>)
{

// check for postback.
if (!this.IsPostBack)
{
// get data reader.
SqlDataReader dr = someCommand.ExecuteReader();
control.DataSource = dr;
control.DataTextField = "SomeTextField";
control.DataValueField = "SomeValueField";
control.DataBind();
}
}

John
-----Original Message-----
From: darrel [mailto:no*****@hotmail.com]
Posted At: Friday, August 26, 2005 1:02 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: My DropDownList handler isn't executing.
Subject: Re: My DropDownList handler isn't executing.

However, my handler doesn't seem to execute (even though there is a
postback).


Hmm...I also have another problem. The auto-postback isn't retaining the
selected value. It keeps reverting to the first item.

I don't normally use drop down auto-postbacks, so am I just completely
not 'getting' some fundamental concept here?

-Darrel
Nov 19 '05 #5
Do they all have unique values?

"darrel" <no*****@hotmail.com> wrote in message
news:eV**************@TK2MSFTNGP14.phx.gbl...
Are you rebinding the data every time the page loads? This may be your
problem. You only need to bind once.


Nope. no databinding at all. Just a simple option list right in the HTML
itself.

-Darrel

Nov 19 '05 #6
> Do they all have unique values?

Yes. Here's the full markup:

<asp:dropdownlist id=ddl_districtSelect runat="server" AutoPostBack="True">
<asp:ListItem Value="first">1st District</asp:ListItem>
<asp:ListItem Value="second">2nd District</asp:ListItem>
<asp:ListItem Value="third">3rd District</asp:ListItem>
<asp:ListItem Value="fourth">4th District</asp:ListItem>
<asp:ListItem Value="fifth">5th District</asp:ListItem>
<asp:ListItem Value="sixth">6th District</asp:ListItem>
<asp:ListItem Value="seventh">7th District</asp:ListItem>
<asp:ListItem Value="eigth">8th District</asp:ListItem>
<asp:ListItem Value="ninth">9th District</asp:ListItem>
<asp:ListItem Value="tenth">10th District</asp:ListItem>
</asp:dropdownlist>

-Darrel
Nov 19 '05 #7
> If your ddl is reverting to the first item and not keeping the selected
item from prior to the postback, you are probably calling databind() on
the control on the postback.


I'm not in this case. Just a static list of asp:listItems

Nowhere in my codebehind am I databinding to this list nor am I even
changing the selected item.

-Darrel
Nov 19 '05 #8
Have you recompiled your project since adding the handler?

If this is all that is going on, then the handler should be getting hit.

"darrel" <no*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Do they all have unique values?


Yes. Here's the full markup:

<asp:dropdownlist id=ddl_districtSelect runat="server"
AutoPostBack="True">
<asp:ListItem Value="first">1st District</asp:ListItem>
<asp:ListItem Value="second">2nd District</asp:ListItem>
<asp:ListItem Value="third">3rd District</asp:ListItem>
<asp:ListItem Value="fourth">4th District</asp:ListItem>
<asp:ListItem Value="fifth">5th District</asp:ListItem>
<asp:ListItem Value="sixth">6th District</asp:ListItem>
<asp:ListItem Value="seventh">7th District</asp:ListItem>
<asp:ListItem Value="eigth">8th District</asp:ListItem>
<asp:ListItem Value="ninth">9th District</asp:ListItem>
<asp:ListItem Value="tenth">10th District</asp:ListItem>
</asp:dropdownlist>

-Darrel

Nov 19 '05 #9
> Have you recompiled your project since adding the handler?

If this is all that is going on, then the handler should be getting hit.


Aaarrrrrrrrrrrrrrggggggggggghhhhhhhhhhhhhhh!

I'm a dope. Turns out there was a stray FORM tag in the HTML (this was a
legacy ASP page that I'm slowly converting).

'doh!

-Darrel
Nov 19 '05 #10
What is the EnableViewState property on the ddl set to? It should be
True.

John

-----Original Message-----
From: darrel [mailto:no*****@hotmail.com]
Posted At: Friday, August 26, 2005 1:27 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: My DropDownList handler isn't executing.
Subject: Re: My DropDownList handler isn't executing.

If your ddl is reverting to the first item and not keeping the
selected item from prior to the postback, you are probably calling
databind() on the control on the postback.


I'm not in this case. Just a static list of asp:listItems

Nowhere in my codebehind am I databinding to this list nor am I even
changing the selected item.

-Darrel
Nov 19 '05 #11
> What is the EnableViewState property on the ddl set to? It should be
True.

John


Hey John. See my other response. THis was a user-error problem. I was
migrating an old ASP page over and had missed a stray FORM tag that was
breaking everything below it.

A typical Friday mind fart on my part. ;o)

-Darrel
Nov 19 '05 #12
Pat
Darrel good you got it working

"darrel" <no*****@hotmail.com> wrote in message
news:O2**************@TK2MSFTNGP12.phx.gbl...
Have you recompiled your project since adding the handler?

If this is all that is going on, then the handler should be getting hit.


Aaarrrrrrrrrrrrrrggggggggggghhhhhhhhhhhhhhh!

I'm a dope. Turns out there was a stray FORM tag in the HTML (this was a
legacy ASP page that I'm slowly converting).

'doh!

-Darrel

Nov 19 '05 #13

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

Similar topics

0
by: DotNetJunkies User | last post by:
Hie, I create a dynamique HtmlTable, in each cell of this HtmlTable put a new control ( dropdownlist,label,..) and then want to create handler so that if i change the select item in the dop downlist...
2
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
5
by: DC Gringo | last post by:
I've got a command button to submit a value from a dropdown list that should then filter a SELECT query. I'm simply appending a WHERE colx = <variableSelectedFromDropdownList>. How do I pass this...
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: Clouds | last post by:
Hi ! How do I add the dynamic event handler for a dropdownlist present in the itemtemplate of a datalist !! I am doing it in the itemdatabound event of the datalist but it doesnt work... I am...
4
by: TheHach | last post by:
Hi. (For information, i'm working in VB.NET) I have a datagrid on my page. On its creation, I add a dropdownlist in each cell, with a different ID each time. This works fine. But now, I...
2
by: glenn | last post by:
Hi folks, I am trying to determine which item in a DropDownList Web control has been selected. I have posted an OnSelectedIndexChanged subroutine in my code with a reference to the subroutine...
1
by: Kevin Blount | last post by:
I have a test script right now that I'm fighting with. The idea is to "simply" have an aspx page with 3 panels, to show 3 "different" forms and then a 4th panel to show the results of processing...
1
by: Brett | last post by:
I have a DropDownList in an ASP.NET web form that is populated with items from a lookup table by binding that DropDownList to a SqlDataSource. However, the items in the lookup table can change over...
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
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,...
0
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...
0
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...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.