i've been dealing with scenarios like this for a long time:
user wants to edit a set of existing data. suppose it's a list of employees.
the user wants to add a new user to the database, while doing a mass update
to all users, so, in this case, we have 5 employees on screen, the user
click's a "Add New User" button, and we add a new set of input fields for
the new user, in addition to the existing 5 sets of input fields. the
complications in a scenario are this:
1. if the user edits some of the fields for the existing users, then adds a
new user, we have to submit the form to get the new fields on screen. now,
we need to go to the database, get a record count of the first five fields
PLUS add a new set of fields for the new employee not yet in the database.
so our page logic now wants to say something like create a total of 6 sets
of input fields, 5 will have data pulled from the existing users in the
database, one set will be totally blank. this isn't too bad, but
2. what if the user edits some of the fields for the existing users, then
clicks the "Add New User" button. we've loaded the data from the database
for the existing 5 users, not the user's edited fields data.
as i say, i've dealt with this kind of thing before, but it's always a big
pain in the ass. i was thinking of just saving everything to the database
when we need to post the page to get the new fields we need and preserve the
user's edits. this means a lot more database transactions, though, so i've
not sure about the costs in terms of server work and page response. anybody
see a problem with this or have a better way of dealing with it?
tks
>> Stay informed about: how to handle editing existing data while adding new data