Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   DropDownList selectedIndexChanged event not firing (http://www.velocityreviews.com/forums/t776033-dropdownlist-selectedindexchanged-event-not-firing.html)

Dabbler 05-06-2005 02:35 PM

DropDownList selectedIndexChanged event not firing
 
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.

Brock Allen 05-06-2005 04:20 PM

Re: DropDownList selectedIndexChanged event not firing
 
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.
>





Dabbler 05-06-2005 04:42 PM

Re: DropDownList selectedIndexChanged event not firing
 
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.
> >

>
>
>
>


Brock Allen 05-06-2005 05:15 PM

Re: DropDownList selectedIndexChanged event not firing
 
> 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






Dabbler 05-06-2005 05:18 PM

Re: DropDownList selectedIndexChanged event not firing
 
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.
> >

>
>
>
>


Dabbler 05-06-2005 05:42 PM

Re: DropDownList selectedIndexChanged event not firing
 
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
>
>
>
>
>
>


Josh Behl 08-13-2006 06:36 AM

Re: DropDownList selectedIndexChanged event not firing
 

"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
>
>
>
>
>
>



All times are GMT. The time now is 07:39 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.