Selected Item On Bound DDL

R

Randy Rubin

Does anyone know how to Make an Item selected in a DropDownListBox when
Binding it to data. When it changes it populates another TextBox but the
DDLB does not retain it's selected value.

Thanks

Randy
 
B

Ben

Don't rebind the control during selected index changed. If you must, store
the selected value, rebind it, then reapply the selected value.
 
R

Randy Rubin

Still Not working.. Here is some code:
Sub Page_Load

If Not IsPostBack Then

lblNotes.Visible = True
txtNotes.Visible = False
btnUpdateNotes.Visible = False

Else
Session("ItemSel") = ddlItem.SelectedItem.Value
ddlItem.SelectedItem.Value = Session("ItemSel")
ddlItem.SelectedItem.Selected = True
End If
End Sub
 
N

Norman Yuan

See comment inline

Randy Rubin said:
Still Not working.. Here is some code:
Sub Page_Load

If Not IsPostBack Then

lblNotes.Visible = True
txtNotes.Visible = False
btnUpdateNotes.Visible = False

Else

I think you should move the first line of code below to
ddlItem_SelectedIndexChanged event handler and erase the other two lines,
UNLESS you really want to ddlItem's selected item change to something else
other than user clicked item.
 

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

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top