Ask a Question related to ASP.NET General, Design and Development.
-
Kevin Spencer #1
Re: SelectedIndexChanged event not firing
Is the AutoPostBack property of the DropDown set to True?
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
[url]http://www.takempis.com[/url]
Complex things are made up of
lots of simple things.
"Joe Bleaux" <joe@bleaux.org> wrote in message
news:%23TzCIyFWDHA.2040@TK2MSFTNGP11.phx.gbl...there> I've got a page with 2 dropdown lists.
>
> Both of them are supposed to redirect (or actually, repost) the page with
> new values in the querystring.
>
> Dropdownlist1 works like it's supposed to, but after a trace warning and a
> breakpoint in the SelectedIndexChanged event for dropdownlist2, I've found
> that the event isn't firing at all. I'm a beginner, to be sure, but I've
> looked through all the code and for every occurance of dropdownlist1,> is a corresponding occurance of dropdownlist2.
>
> How can I fix this?
>
> Thanks
>
>
Kevin Spencer Guest
-
SelectedIndexChanged event is not fired
I've created a Web user control that contains a DropDownList and this DropDownList gets created and loaded in init() everytime. I set... -
SelectedIndexChanged NOT Firing
Hi, SelectedIndexChanged NOT Firing in my DropDown ListBox AutoPostBack = true EnableViewState = True Autpostback works, but the... -
cannot trigger SelectedIndexChanged event
I use data binding function to display data from DB to datagrid. but I don't know why I cannot trigger the SelectedIndexChanged event? -
SelectedIndexChanged event in DropDownList
Hi. Why cannot I capture the SelectedIndexChanged event from a DropDownList when the viewstate is set to false (it must be set to false because of... -
add Javascript code at the end of a SelectedIndexChanged event
I have a webform that searches a database and displays the output in a datagrid. I would like to be able to call a javascript at the end of the... -
Joe Bleaux #2
Re: SelectedIndexChanged event not firing
yes.
That must come up a lot, but my autopostback is definitely set to true. It
does post too... but that's not terribly useful if it doesn't run the event
code.
"Kevin Spencer" <kevin@takempis.com> wrote in message
news:%23$gzLHGWDHA.3088@tk2msftngp13.phx.gbl...with> Is the AutoPostBack property of the DropDown set to True?
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> [url]http://www.takempis.com[/url]
> Complex things are made up of
> lots of simple things.
>
> "Joe Bleaux" <joe@bleaux.org> wrote in message
> news:%23TzCIyFWDHA.2040@TK2MSFTNGP11.phx.gbl...> > I've got a page with 2 dropdown lists.
> >
> > Both of them are supposed to redirect (or actually, repost) the pagea> > new values in the querystring.
> >
> > Dropdownlist1 works like it's supposed to, but after a trace warning andfound> > breakpoint in the SelectedIndexChanged event for dropdownlist2, I'veI've> > that the event isn't firing at all. I'm a beginner, to be sure, but> there> > looked through all the code and for every occurance of dropdownlist1,>> > is a corresponding occurance of dropdownlist2.
> >
> > How can I fix this?
> >
> > Thanks
> >
> >
>
Joe Bleaux Guest
-
Marina #3
Re: SelectedIndexChanged event not firing
In that case please post the relevant pieces of code.
"Joe Bleaux" <joe@bleaux.org> wrote in message
news:%23OicBQGWDHA.1940@TK2MSFTNGP10.phx.gbl...It> yes.
>
> That must come up a lot, but my autopostback is definitely set to true.event> does post too... but that's not terribly useful if it doesn't run theand> code.
>
>
> "Kevin Spencer" <kevin@takempis.com> wrote in message
> news:%23$gzLHGWDHA.3088@tk2msftngp13.phx.gbl...> with> > Is the AutoPostBack property of the DropDown set to True?
> >
> > --
> > HTH,
> >
> > Kevin Spencer
> > Microsoft MVP
> > .Net Developer
> > [url]http://www.takempis.com[/url]
> > Complex things are made up of
> > lots of simple things.
> >
> > "Joe Bleaux" <joe@bleaux.org> wrote in message
> > news:%23TzCIyFWDHA.2040@TK2MSFTNGP11.phx.gbl...> > > I've got a page with 2 dropdown lists.
> > >
> > > Both of them are supposed to redirect (or actually, repost) the page> > > new values in the querystring.
> > >
> > > Dropdownlist1 works like it's supposed to, but after a trace warning> a> found> > > breakpoint in the SelectedIndexChanged event for dropdownlist2, I've> I've> > > that the event isn't firing at all. I'm a beginner, to be sure, but>> > there> > > looked through all the code and for every occurance of dropdownlist1,> >> > > is a corresponding occurance of dropdownlist2.
> > >
> > > How can I fix this?
> > >
> > > Thanks
> > >
> > >
> >
>
Marina Guest
-
Joe Bleaux #4
Re: SelectedIndexChanged event not firing
Upon closer examination, I've realized that when I change dropdownlist2, the
dropdownlist1 event fires, which is even weirder than I thought.
I'm not entirely sure what's relevant here, so here's what I'll post for
now:
This is what the asp side of this ddl looks like:
<asp:DropDownList id="DropDownList2" runat="server"
AutoPostBack="True"></asp:dropdownlist>
And here is the function I call to populate it:
Public Sub filllistb(ByVal ipage As Integer, ByVal totalposts As Integer,
ByVal pagesize As Integer)
Dim I As Integer
Dim newitem As ListItem
For I = 1 To (totalposts / pagesize)
newitem = New ListItem
newitem.Value = I
newitem.Text = I
DropDownList2.Items.Add(newitem)
Next
DropDownList2.Items(ipage - 1).Selected = True
End Sub
And finally, here is the code that never seems to run.
Private Sub DropDownList2_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList2.SelectedIndexChanged
Trace.Warn("dropdownlist2 was called")
Response.Redirect("threads.aspx?ipage=" &
Val(DropDownList2.SelectedValue) & "&pagesize=" &
Val(DropDownList1.SelectedValue))
End Sub
Joe Bleaux Guest
-
Joe Bleaux #5
Re: SelectedIndexChanged event not firing
It may be worth nothing that when I use dropdownlist1, the value that it
gives me for dropdownlist2.selectedvalue is always zero.
"Joe Bleaux" <joe@bleaux.org> wrote in message
news:%23leU%23cGWDHA.2328@TK2MSFTNGP12.phx.gbl...the> Upon closer examination, I've realized that when I change dropdownlist2,> dropdownlist1 event fires, which is even weirder than I thought.
> I'm not entirely sure what's relevant here, so here's what I'll post for
> now:
>
> This is what the asp side of this ddl looks like:
>
> <asp:DropDownList id="DropDownList2" runat="server"
> AutoPostBack="True"></asp:dropdownlist>
>
>
>
> And here is the function I call to populate it:
>
> Public Sub filllistb(ByVal ipage As Integer, ByVal totalposts As Integer,
> ByVal pagesize As Integer)
> Dim I As Integer
> Dim newitem As ListItem
>
> For I = 1 To (totalposts / pagesize)
>
> newitem = New ListItem
>
> newitem.Value = I
>
> newitem.Text = I
>
> DropDownList2.Items.Add(newitem)
>
> Next
>
> DropDownList2.Items(ipage - 1).Selected = True
>
> End Sub
>
>
>
> And finally, here is the code that never seems to run.
>
> Private Sub DropDownList2_SelectedIndexChanged(ByVal sender As
> System.Object, ByVal e As System.EventArgs) Handles
> DropDownList2.SelectedIndexChanged
>
> Trace.Warn("dropdownlist2 was called")
>
> Response.Redirect("threads.aspx?ipage=" &
> Val(DropDownList2.SelectedValue) & "&pagesize=" &
> Val(DropDownList1.SelectedValue))
>
> End Sub
>
>
Joe Bleaux Guest
-
David Wier #6
Re: SelectedIndexChanged event not firing
Try populating the ddl like this:
if not page.ispostback then
'all your population code goes here
end if
David Wier
[url]http://aspnet101.com[/url]
[url]http://aspexpress.com[/url]
"Joe Bleaux" <joe@bleaux.org> wrote in message
news:%23leU%23cGWDHA.2328@TK2MSFTNGP12.phx.gbl...the> Upon closer examination, I've realized that when I change dropdownlist2,> dropdownlist1 event fires, which is even weirder than I thought.
> I'm not entirely sure what's relevant here, so here's what I'll post for
> now:
>
> This is what the asp side of this ddl looks like:
>
> <asp:DropDownList id="DropDownList2" runat="server"
> AutoPostBack="True"></asp:dropdownlist>
>
>
>
> And here is the function I call to populate it:
>
> Public Sub filllistb(ByVal ipage As Integer, ByVal totalposts As Integer,
> ByVal pagesize As Integer)
> Dim I As Integer
> Dim newitem As ListItem
>
> For I = 1 To (totalposts / pagesize)
>
> newitem = New ListItem
>
> newitem.Value = I
>
> newitem.Text = I
>
> DropDownList2.Items.Add(newitem)
>
> Next
>
> DropDownList2.Items(ipage - 1).Selected = True
>
> End Sub
>
>
>
> And finally, here is the code that never seems to run.
>
> Private Sub DropDownList2_SelectedIndexChanged(ByVal sender As
> System.Object, ByVal e As System.EventArgs) Handles
> DropDownList2.SelectedIndexChanged
>
> Trace.Warn("dropdownlist2 was called")
>
> Response.Redirect("threads.aspx?ipage=" &
> Val(DropDownList2.SelectedValue) & "&pagesize=" &
> Val(DropDownList1.SelectedValue))
>
> End Sub
>
>
David Wier Guest
-
David Wier #7
Re: SelectedIndexChanged event not firing
Check out this code sample and see if it can give you any hints - - it
dynamically populates 3 dropdownlists, dependant on the each previous one
[url]http://aspnet101.com/aspnet101/aspnet/codesample.aspx?code=ddl3MDB[/url]
David Wier
[url]http://aspnet101.com[/url]
[url]http://aspexpress.com[/url]
"Joe Bleaux" <joe@bleaux.org> wrote in message
news:ejwN3zGWDHA.652@tk2msftngp13.phx.gbl...dropdownlist> That won't work for me because the items in the second dropdownlist are
> dependant on the item selected in the first dropdown list, so it needs to
> populate each time.
>
> This is for a newsreader web app.
>
> The first dropdown list indicates the number of items per page, and the
> second dropdown indicates the page.
>
> If I have 200 messages, and 10 items per page, then the secondpage,> has 20 items, since there are 20 pages. But if there are 20 items perfiring.> then the second dropdown list will have only 10 items.
>
> I hope that makes sense. And I hope it doesn't keep the event fromdropdownlist2,>
> Thanks
>
> "David Wier" <dwier@nospamASPNet101.com> wrote in message
> news:%23aWeMuGWDHA.2476@tk2msftngp13.phx.gbl...> > Try populating the ddl like this:
> > if not page.ispostback then
> > 'all your population code goes here
> > end if
> >
> >
> > David Wier
> > [url]http://aspnet101.com[/url]
> > [url]http://aspexpress.com[/url]
> >
> >
> > "Joe Bleaux" <joe@bleaux.org> wrote in message
> > news:%23leU%23cGWDHA.2328@TK2MSFTNGP12.phx.gbl...> > > Upon closer examination, I've realized that when I changefor> > the> > > dropdownlist1 event fires, which is even weirder than I thought.
> > > I'm not entirely sure what's relevant here, so here's what I'll post> Integer,> > > now:
> > >
> > > This is what the asp side of this ddl looks like:
> > >
> > > <asp:DropDownList id="DropDownList2" runat="server"
> > > AutoPostBack="True"></asp:dropdownlist>
> > >
> > >
> > >
> > > And here is the function I call to populate it:
> > >
> > > Public Sub filllistb(ByVal ipage As Integer, ByVal totalposts As>> >> > > ByVal pagesize As Integer)
> > > Dim I As Integer
> > > Dim newitem As ListItem
> > >
> > > For I = 1 To (totalposts / pagesize)
> > >
> > > newitem = New ListItem
> > >
> > > newitem.Value = I
> > >
> > > newitem.Text = I
> > >
> > > DropDownList2.Items.Add(newitem)
> > >
> > > Next
> > >
> > > DropDownList2.Items(ipage - 1).Selected = True
> > >
> > > End Sub
> > >
> > >
> > >
> > > And finally, here is the code that never seems to run.
> > >
> > > Private Sub DropDownList2_SelectedIndexChanged(ByVal sender As
> > > System.Object, ByVal e As System.EventArgs) Handles
> > > DropDownList2.SelectedIndexChanged
> > >
> > > Trace.Warn("dropdownlist2 was called")
> > >
> > > Response.Redirect("threads.aspx?ipage=" &
> > > Val(DropDownList2.SelectedValue) & "&pagesize=" &
> > > Val(DropDownList1.SelectedValue))
> > >
> > > End Sub
> > >
> > >
> >
>
David Wier Guest
-
Joe Bleaux #8
Re: SelectedIndexChanged event not firing
Thanks, that fixed it up. I'm not sure why... I guess I was populating the
list too late.
-Mike
"David Wier" <dwier@nospamASPNet101.com> wrote in message
news:e1RKw6GWDHA.1368@TK2MSFTNGP11.phx.gbl...to> Check out this code sample and see if it can give you any hints - - it
> dynamically populates 3 dropdownlists, dependant on the each previous one
> [url]http://aspnet101.com/aspnet101/aspnet/codesample.aspx?code=ddl3MDB[/url]
>
> David Wier
> [url]http://aspnet101.com[/url]
> [url]http://aspexpress.com[/url]
>
>
> "Joe Bleaux" <joe@bleaux.org> wrote in message
> news:ejwN3zGWDHA.652@tk2msftngp13.phx.gbl...> > That won't work for me because the items in the second dropdownlist are
> > dependant on the item selected in the first dropdown list, so it needs> dropdownlist> > populate each time.
> >
> > This is for a newsreader web app.
> >
> > The first dropdown list indicates the number of items per page, and the
> > second dropdown indicates the page.
> >
> > If I have 200 messages, and 10 items per page, then the second> page,> > has 20 items, since there are 20 pages. But if there are 20 items per> firing.> > then the second dropdown list will have only 10 items.
> >
> > I hope that makes sense. And I hope it doesn't keep the event from> dropdownlist2,> >
> > Thanks
> >
> > "David Wier" <dwier@nospamASPNet101.com> wrote in message
> > news:%23aWeMuGWDHA.2476@tk2msftngp13.phx.gbl...> > > Try populating the ddl like this:
> > > if not page.ispostback then
> > > 'all your population code goes here
> > > end if
> > >
> > >
> > > David Wier
> > > [url]http://aspnet101.com[/url]
> > > [url]http://aspexpress.com[/url]
> > >
> > >
> > > "Joe Bleaux" <joe@bleaux.org> wrote in message
> > > news:%23leU%23cGWDHA.2328@TK2MSFTNGP12.phx.gbl...
> > > > Upon closer examination, I've realized that when I change> for> > > the
> > > > dropdownlist1 event fires, which is even weirder than I thought.
> > > > I'm not entirely sure what's relevant here, so here's what I'll post>> > Integer,> > > > now:
> > > >
> > > > This is what the asp side of this ddl looks like:
> > > >
> > > > <asp:DropDownList id="DropDownList2" runat="server"
> > > > AutoPostBack="True"></asp:dropdownlist>
> > > >
> > > >
> > > >
> > > > And here is the function I call to populate it:
> > > >
> > > > Public Sub filllistb(ByVal ipage As Integer, ByVal totalposts As> >> > > > ByVal pagesize As Integer)
> > > > Dim I As Integer
> > > > Dim newitem As ListItem
> > > >
> > > > For I = 1 To (totalposts / pagesize)
> > > >
> > > > newitem = New ListItem
> > > >
> > > > newitem.Value = I
> > > >
> > > > newitem.Text = I
> > > >
> > > > DropDownList2.Items.Add(newitem)
> > > >
> > > > Next
> > > >
> > > > DropDownList2.Items(ipage - 1).Selected = True
> > > >
> > > > End Sub
> > > >
> > > >
> > > >
> > > > And finally, here is the code that never seems to run.
> > > >
> > > > Private Sub DropDownList2_SelectedIndexChanged(ByVal sender As
> > > > System.Object, ByVal e As System.EventArgs) Handles
> > > > DropDownList2.SelectedIndexChanged
> > > >
> > > > Trace.Warn("dropdownlist2 was called")
> > > >
> > > > Response.Redirect("threads.aspx?ipage=" &
> > > > Val(DropDownList2.SelectedValue) & "&pagesize=" &
> > > > Val(DropDownList1.SelectedValue))
> > > >
> > > > End Sub
> > > >
> > > >
> > >
> > >
> >
>
Joe Bleaux Guest
-
Severin #9
Re: SelectedIndexChanged event not firing
Many times I come across an event that just doesn't work, won't do a
thing.....
Most times (19 out of 20) it is because somewhere along the road the Handles
Clause has mysteriously disappeared.
such as:
Private Sub Calendar1_SelectionChanged(sender as object, e as EventArgs)
Handles Calendar1.SelectionChanged
End Sub
I do not know what causes the Handles Clause to go poof, but like I said
Most Times that is the reason
Severin
"Joe Bleaux" <joe@bleaux.org> wrote in message
news:%23TzCIyFWDHA.2040@TK2MSFTNGP11.phx.gbl...there> I've got a page with 2 dropdown lists.
>
> Both of them are supposed to redirect (or actually, repost) the page with
> new values in the querystring.
>
> Dropdownlist1 works like it's supposed to, but after a trace warning and a
> breakpoint in the SelectedIndexChanged event for dropdownlist2, I've found
> that the event isn't firing at all. I'm a beginner, to be sure, but I've
> looked through all the code and for every occurance of dropdownlist1,> is a corresponding occurance of dropdownlist2.
>
> How can I fix this?
>
> Thanks
>
>
Severin Guest



Reply With Quote

