Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListBox.SelectedIndexChanged not changing

Status
Not open for further replies.

ityles

Programmer
Apr 15, 2002
6
US
This is related to the "Freaky listbox problem" post, here's a bit more of a description of its behaviour...

I have a listbox which gets filled initially in the page_load within an "If not page.ispostback" and there are say, 4 items in it, no item is yet selected.

When the user clicks on an item, the ListBox.SelectedIndexChanged event-sub gets called (autopostback=true). The very first time you select an item, it acknowledges the changed index and works fine (calls another sub that refills the listbox with the appropriate list depending on what you selected).

The problem is, every other time after that, when the SelectedIndexChanged event-sub gets called the Selected index is always 0, no matter what you just selected! Is the postback wiping everything out before it's getting to the SelectedIndexChanged event? How can you "catch" the selected item before it gets erased?


Here's the event-sub, any ideas?

----------------------------------------
Private Sub lstHeadings_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstHeadings.SelectedIndexChanged

Dim strWholePath As String
lblHeadingName.Text = lstHeadings.SelectedItem.Text
strWholePath = Server.MapPath("..\Help\XML\" & lstHeadings.SelectedItem.Value)
FillLists(lstHeadings.SelectedItem.Text, strWholePath)

End Sub
----------------------------------------

Thanks!
I.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top