FormView and DropDownList

M

Maciejka

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
 
D

dotNetNewbie

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!
 

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,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top