SelectedIndexChanged event not firing

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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...
    > 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,
    there
    > is a corresponding occurance of dropdownlist2.
    >
    > How can I fix this?
    >
    > Thanks
    >
    >

    Kevin Spencer Guest

  2. Similar Questions and Discussions

    1. 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...
    2. SelectedIndexChanged NOT Firing
      Hi, SelectedIndexChanged NOT Firing in my DropDown ListBox AutoPostBack = true EnableViewState = True Autpostback works, but the...
    3. 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?
    4. 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...
    5. 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...
  3. #2

    Default 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...
    > 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
    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,
    > there
    > > is a corresponding occurance of dropdownlist2.
    > >
    > > How can I fix this?
    > >
    > > Thanks
    > >
    > >
    >
    >

    Joe Bleaux Guest

  4. #3

    Default 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...
    > 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...
    > > 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
    > 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,
    > > there
    > > > is a corresponding occurance of dropdownlist2.
    > > >
    > > > How can I fix this?
    > > >
    > > > Thanks
    > > >
    > > >
    > >
    > >
    >
    >

    Marina Guest

  5. #4

    Default 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

  6. #5

    Default 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...
    > 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

  7. #6

    Default 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...
    > 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
    >
    >

    David Wier Guest

  8. #7

    Default 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...
    > 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 second
    dropdownlist
    > has 20 items, since there are 20 pages. But if there are 20 items per
    page,
    > 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
    firing.
    >
    > 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
    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
    > > >
    > > >
    > >
    > >
    >
    >

    David Wier Guest

  9. #8

    Default 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...
    > 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
    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 second
    > dropdownlist
    > > has 20 items, since there are 20 pages. But if there are 20 items per
    > page,
    > > 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
    > firing.
    > >
    > > 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
    > 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

  10. #9

    Default 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...
    > 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,
    there
    > is a corresponding occurance of dropdownlist2.
    >
    > How can I fix this?
    >
    > Thanks
    >
    >

    Severin Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139