Why does the dropdownlist always select the same item ?

liunx

Guest
Hello, I use a drop downlist "txtmajor" to retrieve data from sql server.

txtmajor.Items.clear()
While reader.Read()
txtmajor.Items.Add(reader.Item("No") & "/" & reader.Item("Subject"))
End While

But when I use txtmajor.SelectedItem.Text.ToString to show the selected item, it is always the first item. How can I solve the problem ?I'd say you've got a logical error somewhere that's causing the box to reload whenever you try to do your txtmajor.SelectedItem.Text.ToString deal. Can I see more of the page's code?Are you binding the list on every post back.

Probably need to check to see

Not isPostBack
then bindlist

Eric
 
Back
Top