dropdown list not keeping selection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a dropdown list box and a button on a web form, the autopost back is
false for the dropdown list box and button. When the button is pushed the
selection in the dropdownlist box is lost, just wondering what is wrong.

Selected value is always 1 no matter what is selected in the dropdown list
box.

Private Sub btn_yes_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_yes.Click
Dim s_origidval As String
s_origidval = Me.dr_orig.SelectedValue
End SubThanks
 
You did not provide enough code to diagnose the problem. First guess would
be that you are repopulating the dropdown in page_load every time, instead
of just the first.
 
thanks for the response, yep forgot to include
if Not Page.IsPostBack
in the page load
Marina said:
You did not provide enough code to diagnose the problem. First guess would
be that you are repopulating the dropdown in page_load every time, instead
of just the first.
 
Did you set value for each ListItem? There are Text and Value properties for
each ListItem. What does Items of ListBox property look like which contain
all ListItems.

Shaw


Paul said:
thanks for the response, yep forgot to include
if Not Page.IsPostBack
in the page load
 
Yep, populating the listbox with a dataset, and then in the code binding the
control
Me.dropdown.DataBind() 'bind data to drop down list.
I also have the datasource set to the dataset in the properties box of the
dropdown list box, seems to be working now.
 
Back
Top