Selected Item On Bound DDL

Discussion in 'ASP .Net' started by Randy Rubin, Jul 15, 2004.

  1. Randy Rubin

    Randy Rubin Guest

    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
     
    Randy Rubin, Jul 15, 2004
    #1
    1. Advertising

  2. Randy Rubin

    Ben Guest

    Don't rebind the control during selected index changed. If you must, store
    the selected value, rebind it, then reapply the selected value.
    "Randy Rubin" <> wrote in message
    news:...
    > 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
    >
    >
     
    Ben, Jul 15, 2004
    #2
    1. Advertising

  3. Randy Rubin

    Randy Rubin Guest

    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
    "Ben" <> wrote in message
    news:89BJc.93$...
    > Don't rebind the control during selected index changed. If you must,

    store
    > the selected value, rebind it, then reapply the selected value.
    > "Randy Rubin" <> wrote in message
    > news:...
    > > 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
    > >
    > >

    >
    >
    >
     
    Randy Rubin, Jul 15, 2004
    #3
  4. Randy Rubin

    Norman Yuan Guest

    See comment inline

    "Randy Rubin" <> wrote in message
    news:uXro$...
    > 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.

    > Session("ItemSel") = ddlItem.SelectedItem.Value
    > ddlItem.SelectedItem.Value = Session("ItemSel")
    > ddlItem.SelectedItem.Selected = True
    > End If
    > End Sub
    > "Ben" <> wrote in message
    > news:89BJc.93$...
    > > Don't rebind the control during selected index changed. If you must,

    > store
    > > the selected value, rebind it, then reapply the selected value.
    > > "Randy Rubin" <> wrote in message
    > > news:...
    > > > 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
    > > >
    > > >

    > >
    > >
    > >

    >
    >
     
    Norman Yuan, Jul 15, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marina
    Replies:
    6
    Views:
    13,638
    KROSS
    Jan 21, 2008
  2. Marina
    Replies:
    0
    Views:
    952
    Marina
    Aug 12, 2003
  3. Iain
    Replies:
    3
    Views:
    971
  4. Jim in Arizona
    Replies:
    0
    Views:
    457
    Jim in Arizona
    Apr 5, 2007
  5. mldardy
    Replies:
    0
    Views:
    1,001
    mldardy
    Sep 28, 2010
Loading...

Share This Page