Re: now desparate! - 1st listbox contents disappears when 2nd listbox appears?

Discussion in 'ASP .Net' started by blenderdude, Aug 3, 2003.

  1. blenderdude

    blenderdude Guest

    On 23 Jun 2003 12:57:45 -0700, (KathyB) wrote:

    >Hi, I'm back.
    >
    >I have two dropdownlist server controls. #1 populates on pageload -
    >works fine.
    >#2 also populates fine (on #1 selecteditemchanged event).
    >
    >My problem is that I need to RETAIN the value selected in #1 so the
    >user sees it, and also I will need to capture it as a variable to pass
    >on to the next pages reload...I though ViewState did that for me, but
    >doesn't appear to be working.
    >
    >I have #1 set to viewstate = true and autopostback = true.
    >
    >I've set the code to be If Not IsPostBack, etc. Could someone PLEASE
    >tell me where I'm going wrong and/or how to accomplish the above? Code
    >follows.
    >
    >Thanks! Kathy


    Its been a while since you posted but I will answer anyway. The
    problem is on the following two lines. You are binding the entire form
    and the will reset the users selection on the listbox.
    > Me.DataBind()
    > Me.DataBind()


    Instead you should only bind that particular listbox, as in:

    listbox1.databind
    listbox2.databind

    that way the second databind won't affect the users selection in the
    first textbox.

    Mike
    blenderdude, Aug 3, 2003
    #1
    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. Erik Funkenbusch
    Replies:
    2
    Views:
    1,918
    Ken Cox - Microsoft MVP
    Mar 26, 2006
  2. stopchuckingstuff

    Confusing, desparate MySQLdb problems...

    stopchuckingstuff, Jan 16, 2010, in forum: Python
    Replies:
    13
    Views:
    797
    Ned Deily
    Jan 17, 2010
  3. Ryan Saunders
    Replies:
    6
    Views:
    160
    Gunnar Hjalmarsson
    Sep 7, 2004
  4. Phil Powell
    Replies:
    3
    Views:
    88
    Phil Powell
    Jul 25, 2005
  5. pk
    Replies:
    7
    Views:
    171
Loading...

Share This Page