Selected Item On Bound DDL

  • Thread starter Thread starter Randy Rubin
  • Start date Start date
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
 
Don't rebind the control during selected index changed. If you must, store
the selected value, rebind it, then reapply the selected value.
 
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
 
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

Back
Top