James Posted January 31, 2003 Posted January 31, 2003 I have a drop down list box that does not post back properly. When the drop down list item changes the OnSelectedIndexChanged event triggers it run the Page_Load subroutine with no problems, but it does not run the ddDetails_SelectedIndexChanged subroutine like it's suppose to. Does anyone know why? All my other drop downs work fine. I don't know what's happening. I do not get a run-time error. Drop down code is below webcontrol: <asp:dropdownlist id="ddDetails" runat="server" OnSelectedIndexChanged="ddDetails_SelectedIndexChanged" AutoPostBack="True"> code behind: Sub ddDetails_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) getIt() End Sub James Quote
Moderators Robby Posted January 31, 2003 Moderators Posted January 31, 2003 do you have a handler... Sub ddDetails_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles ddDetails.SelectedIndexChanged getIt() End Sub Quote Visit...Bassic Software
James Posted January 31, 2003 Author Posted January 31, 2003 I do have a handler. The code post does not because I removed it to see if it would help. It doesn't. James Quote
Moderators Robby Posted January 31, 2003 Moderators Posted January 31, 2003 Is the event in the code-behind or on the aspx file? Quote Visit...Bassic Software
aikeith Posted January 31, 2003 Posted January 31, 2003 Dont not specify the handler in both the code-behind and the aspx page. Hence remove: OnSelectedIndexChanged="ddDetails_SelectedIndexChanged" and on the code-behind Public Sub Poopy(ByVal sender As Object, e As EventArgs) Handles ddDetails_SelectedIndexChanged ' put your big bad code here End Sub If that is not the problem, then verify that the state is being kept, the function/sub that loads the dropdown is NOT being run on a post back. I ran into this big time when I was dynamically creating the menues from a db. Hope that helps. Quote
James Posted February 3, 2003 Author Posted February 3, 2003 The code is in a code behind. I remove the onselectChange from my dropdown but it still doesn't work. How do I know if the state is being kept? The sub that loads the dropdown is the Page_Load it run and loads the dropdown but the sub that is call when I change the selected item does not run. James Quote
Moderators Robby Posted February 3, 2003 Moderators Posted February 3, 2003 Did you design the form in the designer? trace this (code-behind).... Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not IsPostBack Then 'place something here else 'place something here end if Quote Visit...Bassic Software
James Posted February 3, 2003 Author Posted February 3, 2003 Yes I designed the form in the designer. When I change an Item in the drop down the code should start with the Load_Page sub. Once that finishes then the sub for my dropdown onselectchanged should run. I know that the following code in my Load_Page works because I step through it in debug mode: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not IsPostBack Then 'place something here Else 'place something here End If end sub However, my drop down onselectchanged does not run The code stop after the Page_Load sub ends. James Quote
Moderators Robby Posted February 3, 2003 Moderators Posted February 3, 2003 I have a silly question, does the dropDown have runat="server" ? Quote Visit...Bassic Software
James Posted February 3, 2003 Author Posted February 3, 2003 Yes the dropdown has a runat=server. The text and values for my dropdown are: value text 1 Dallas 2 Dallas 3 Dallas 1 NY 2 NY When I select any of the "Dallas" items my code works. But when I select a different item like "NY" my code doesn't work. Any thoughts? Quote
Moderators Robby Posted February 3, 2003 Moderators Posted February 3, 2003 You mean that if you select Dallas the onselectChange is triggered and NY is not triggered? Quote Visit...Bassic Software
James Posted February 3, 2003 Author Posted February 3, 2003 Robby, yes that's what's happening now. I think I solve the problem. I don't think I can have duplicate values in a dropdown control. I changed the following and it works. Can a dropdown have duplicate value even if the text is different? 1 Dallas 1 Dallas 2 Dallas 2 Dallas 3 Dallas to 3 Dallas 1 NY 4 NY 2 NY 5 NY James Quote
Moderators Robby Posted February 3, 2003 Moderators Posted February 3, 2003 Can a dropdown have duplicate value even if the text is different Value no, text yes. Quote Visit...Bassic Software
James Posted February 3, 2003 Author Posted February 3, 2003 Thanks Robby that answer the question to my problem. I hate finding out the hard way. But it seem to be the best way to learn at times. James Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.