dropdown list not keeping selection

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
 
M

Marina

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

Guest

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

Guest

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
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top