Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > DropDownList selectedIndexChanged event not firing

Reply
Thread Tools

DropDownList selectedIndexChanged event not firing

 
 
Dabbler
Guest
Posts: n/a
 
      05-06-2005
My dropdown list with autopostback set to true is returning to the
application but my even handler for selectedIndexChanged isn't firing.
in InitializeComponent I have:
AddHandler Me.BrandSearch.SelectedIndexChanged, New EventHandler(AddressOf
Me.BrandSearch_SelectedIndexChanged)

in the handler I have:
Private Sub BrandSearch_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles BrandSearch.SelectedIndexChanged
Trace.Write("leftcolumNav", "insided index changed handler")
End Sub

Page Trace shows new value in variable, but the trace in event handler
doesn't appear.

Using .NET 1.1

Any suggestions would be greatly appreciated.
 
Reply With Quote
 
 
 
 
Brock Allen
Guest
Posts: n/a
 
      05-06-2005
Is it possible that you're rebuilding the list upon postback. This could
cause it to lose memory of the event, so to speak.

-Brock
DevelopMentor
http://staff.develop.com/ballen



> My dropdown list with autopostback set to true is returning to the
> application but my even handler for selectedIndexChanged isn't firing.
> in InitializeComponent I have:
> AddHandler Me.BrandSearch.SelectedIndexChanged, New
> EventHandler(AddressOf
> Me.BrandSearch_SelectedIndexChanged)
> in the handler I have:
> Private Sub BrandSearch_SelectedIndexChanged(ByVal sender As
> System.Object,
> ByVal e As System.EventArgs) Handles BrandSearch.SelectedIndexChanged
> Trace.Write("leftcolumNav", "insided index changed handler")
> End Sub
> Page Trace shows new value in variable, but the trace in event handler
> doesn't appear.
>
> Using .NET 1.1
>
> Any suggestions would be greatly appreciated.
>




 
Reply With Quote
 
 
 
 
Dabbler
Guest
Posts: n/a
 
      05-06-2005
Thanks for you reply, Brock.

I tried it both ways. If I build the dropdownlist contents in Not IsPostBack
then the original page just refreshes with an empty list. The event does not
fire. I can test for changed index in IsPostBack but that's such a kludge.
Note the dropdownlist control is inside an ascx file and so is the handler. I
don't think that should matter. This is mod to StoreFront shopping cart which
by definition is a PITA to work with

Thanks again.

"Brock Allen" wrote:

> Is it possible that you're rebuilding the list upon postback. This could
> cause it to lose memory of the event, so to speak.
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
> > My dropdown list with autopostback set to true is returning to the
> > application but my even handler for selectedIndexChanged isn't firing.
> > in InitializeComponent I have:
> > AddHandler Me.BrandSearch.SelectedIndexChanged, New
> > EventHandler(AddressOf
> > Me.BrandSearch_SelectedIndexChanged)
> > in the handler I have:
> > Private Sub BrandSearch_SelectedIndexChanged(ByVal sender As
> > System.Object,
> > ByVal e As System.EventArgs) Handles BrandSearch.SelectedIndexChanged
> > Trace.Write("leftcolumNav", "insided index changed handler")
> > End Sub
> > Page Trace shows new value in variable, but the trace in event handler
> > doesn't appear.
> >
> > Using .NET 1.1
> >
> > Any suggestions would be greatly appreciated.
> >

>
>
>
>

 
Reply With Quote
 
Brock Allen
Guest
Posts: n/a
 
      05-06-2005
> I tried it both ways. If I build the dropdownlist contents in Not
> IsPostBack then the original page just refreshes with an empty list.
> The event does not fire. I can test for changed index in IsPostBack
> but that's such a kludge. Note the dropdownlist control is inside an
> ascx file and so is the handler. I don't think that should matter.
> This is mod to StoreFront shopping cart which by definition is a PITA
> to work with


Unless you've disabled ViewState, then you should only build the DDL when
IsPostBack==false. So this wounds like to me you've disabled ViewState? If
that's the case, then always build your DDL in Page_Init and you should see
better results.

-Brock
DevelopMentor
http://staff.develop.com/ballen





 
Reply With Quote
 
Dabbler
Guest
Posts: n/a
 
      05-06-2005
Ok when I trace the postback SelectedIndex value I get -1. That implies that
the DropDownList object is no longer loaded with options. The options need to
be loaded at dynamically in Page_Load and that works, because I see the
options. Any suggestions on what I'm doing wrong?

Thanks much.

"Brock Allen" wrote:

> Is it possible that you're rebuilding the list upon postback. This could
> cause it to lose memory of the event, so to speak.
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
> > My dropdown list with autopostback set to true is returning to the
> > application but my even handler for selectedIndexChanged isn't firing.
> > in InitializeComponent I have:
> > AddHandler Me.BrandSearch.SelectedIndexChanged, New
> > EventHandler(AddressOf
> > Me.BrandSearch_SelectedIndexChanged)
> > in the handler I have:
> > Private Sub BrandSearch_SelectedIndexChanged(ByVal sender As
> > System.Object,
> > ByVal e As System.EventArgs) Handles BrandSearch.SelectedIndexChanged
> > Trace.Write("leftcolumNav", "insided index changed handler")
> > End Sub
> > Page Trace shows new value in variable, but the trace in event handler
> > doesn't appear.
> >
> > Using .NET 1.1
> >
> > Any suggestions would be greatly appreciated.
> >

>
>
>
>

 
Reply With Quote
 
Dabbler
Guest
Posts: n/a
 
      05-06-2005
Ok that was it, the original page had view state disabled. When I turned it
back on the dropdownlist event works.

Thanks a bunch, I've spent hours on this rather simple mod!

"Brock Allen" wrote:

> > I tried it both ways. If I build the dropdownlist contents in Not
> > IsPostBack then the original page just refreshes with an empty list.
> > The event does not fire. I can test for changed index in IsPostBack
> > but that's such a kludge. Note the dropdownlist control is inside an
> > ascx file and so is the handler. I don't think that should matter.
> > This is mod to StoreFront shopping cart which by definition is a PITA
> > to work with

>
> Unless you've disabled ViewState, then you should only build the DDL when
> IsPostBack==false. So this wounds like to me you've disabled ViewState? If
> that's the case, then always build your DDL in Page_Init and you should see
> better results.
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
>
>
>

 
Reply With Quote
 
Josh Behl
Guest
Posts: n/a
 
      08-13-2006

"then always build your DDL in Page_Init and you should see
> better results"....that's the one that did it for me! Wow, what a pain. That helped me a ton. Nothing else worked until I found this post. Thank!


Josh
"Brock Allen" wrote:

> > I tried it both ways. If I build the dropdownlist contents in Not
> > IsPostBack then the original page just refreshes with an empty list.
> > The event does not fire. I can test for changed index in IsPostBack
> > but that's such a kludge. Note the dropdownlist control is inside an
> > ascx file and so is the handler. I don't think that should matter.
> > This is mod to StoreFront shopping cart which by definition is a PITA
> > to work with

>
> Unless you've disabled ViewState, then you should only build the DDL when
> IsPostBack==false. So this wounds like to me you've disabled ViewState? If
> that's the case, then always build your DDL in Page_Init and you should see
> better results.
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
>
>
>

 
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
dropdownlist selectedIndexChanged event not firing =?Utf-8?B?Q3VybHlGcm8=?= ASP .Net 1 08-14-2005 04:21 PM
DropDownList SelectedIndexChanged event not firing when in a panel Paul Lacey ASP .Net 2 02-17-2005 09:51 AM
DropDownList.SelectedIndexChanged event not firing BentleyInc ASP .Net Web Controls 4 12-14-2004 04:58 AM
SelectedIndexChanged event of a DropDownList sometimes not firing Lew Barnesson ASP .Net 3 12-04-2004 07:56 PM
dropdownlist selectedindexchanged event not firing.. please help. DesignerX ASP .Net 2 11-14-2003 03:25 PM



Advertisments