Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > My DropDownList handler isn't executing.

Reply
Thread Tools

My DropDownList handler isn't executing.

 
 
darrel
Guest
Posts: n/a
 
      08-26-2005
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


 
Reply With Quote
 
 
 
 
darrel
Guest
Posts: n/a
 
      08-26-2005
> 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


 
Reply With Quote
 
 
 
 
Marina
Guest
Posts: n/a
 
      08-26-2005
Are you rebinding the data every time the page loads? This may be your
problem. You only need to bind once.

"darrel" <> wrote in message
news:%...
>> 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
>
>



 
Reply With Quote
 
darrel
Guest
Posts: n/a
 
      08-26-2005

> 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


 
Reply With Quote
 
Marina
Guest
Posts: n/a
 
      08-26-2005
Do they all have unique values?

"darrel" <> wrote in message
news:...
>
>> 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
>
>



 
Reply With Quote
 
John Horst
Guest
Posts: n/a
 
      08-26-2005
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 [private.php?do=newpm&u=]
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


 
Reply With Quote
 
darrel
Guest
Posts: n/a
 
      08-26-2005
> 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


 
Reply With Quote
 
darrel
Guest
Posts: n/a
 
      08-26-2005
> 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


 
Reply With Quote
 
Marina
Guest
Posts: n/a
 
      08-26-2005
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" <> wrote in message
news:%...
>> 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
>
>



 
Reply With Quote
 
darrel
Guest
Posts: n/a
 
      08-26-2005
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How does a handler render the request to another handler in the MVC of SPRING 2.0.1 framework? rayzyang@gmail.com Java 0 05-30-2007 11:28 AM
Event Handler that creates adds another event handler kaczmar2@gmail.com ASP .Net 1 02-22-2007 07:37 AM
Dropdownlist event handler isn't firing on user control kimberly.walker@consultant.com ASP .Net 0 03-19-2006 07:45 PM
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
passing a value to an event handler from dropdownlist DC Gringo ASP .Net 5 03-03-2004 12:26 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57