Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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.

Posted

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

  • Moderators
Posted

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

Visit...Bassic Software
Posted

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

Posted

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?

Posted

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

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...