FormView and DropDownList

Discussion in 'ASP .Net Web Controls' started by Maciejka, May 24, 2006.

  1. Maciejka

    Maciejka Guest

    I have a problem with formviews and DropDownLists in ASP.NET 2.0. I'm
    using a formview to insert an order into a database. Part of the order
    is a Driver's name. Currently, I have a dropdownlist bound to a
    database that simply selects all drivers from a database table. After
    inserting the data, the DropDownList is cleared and the first driver
    from the table is selected. I would like the system to remember the
    last driver's name which I entered after insering row. It would make it

    easier for me to enter several routes for one driver. Could anybody
    help me solve this problem? Thanks.
    Maciejka
    Maciejka, May 24, 2006
    #1
    1. Advertising

  2. Maciejka

    dotNetNewbie Guest

    Interesting problem. I have it also. In my application, I have several panels
    that become visible when different buttons are pushed, and each panel has a
    gridview that depends upon the selected value in the dropdown. Initially, I
    insert a record based upon the dropdown selected value, using the insert
    parameters of the SQLDataSource (I'm sending parms to a stored insert
    procedure). After the form makes its roundtrip to the server and kicks off
    the stored procedure, it is reconstructed on the client with the dropdown box
    empty. However, if I leave the dropdown alone, and then click another button
    to populate a gridview based upon the selected value in my dropdown, it
    executes correctly, based upon the previously selected value. So the selected
    value survives that round trip to the server, though the displayed value text
    does not.

    Another clue: When I select a value in the dropdown but don't submit it, and
    then click another button that uses a different SQLDataSource, a round trip
    is made and the dropdown retains its displayed, selected value. So the view
    state persistence appears to be enabled for the dropdown.

    I'm new at this game, but I thought that in VS.Net 2005, the controls were
    supposed to persist their viewstates, providing EnableViewState is True
    (which it is on both the dropdown and the SQLDataSource). Either there is an
    attribute that is not set correctly, or perhaps there is something screwy
    going on with the SQLDataSource insert command, which causes the persistence
    of the text value to be lost.

    I'm hoping that someone here has solved this problem, and will help us both!



    "Maciejka" wrote:

    > I have a problem with formviews and DropDownLists in ASP.NET 2.0. I'm
    > using a formview to insert an order into a database. Part of the order
    > is a Driver's name. Currently, I have a dropdownlist bound to a
    > database that simply selects all drivers from a database table. After
    > inserting the data, the DropDownList is cleared and the first driver
    > from the table is selected. I would like the system to remember the
    > last driver's name which I entered after insering row. It would make it
    >
    > easier for me to enter several routes for one driver. Could anybody
    > help me solve this problem? Thanks.
    > Maciejka
    >
    >
    dotNetNewbie, May 25, 2006
    #2
    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. Theam Kok Ming

    Formview and DropDownlist

    Theam Kok Ming, Oct 11, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    396
    Theam Kok Ming
    Oct 11, 2006
  2. Good

    FormView and DropDownList

    Good, Apr 10, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    353
  3. Chris

    Formview within Formview

    Chris, May 19, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    504
    Chris
    May 19, 2007
  4. David Thielen

    FormView/Repeater/ Eval(FormView data)

    David Thielen, Jun 16, 2006, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    621
    David Thielen
    Jun 16, 2006
  5. Lagrange
    Replies:
    1
    Views:
    544
    Lagrange
    Jan 17, 2009
Loading...

Share This Page