So here I am in a stateless environment where the user is editing a single row in my DataGrid. I have bound my DataGrid to an EntityCollection, but by the time the web page is rendered to the screen, that EntityCollection has since disappeared.
When they click the "Update" link in the grid, obviously my UpdateCommand event fires in the grid and I have a DataGridCommandEventArgs argument in this method to deal with.
What do you all do in this case to save your changes to an entity?
I could call a method in my manager class called SaveMyEntity(MyEntity ent) and let it do the work, BUT that means that my presentation layer has to create an instance of MyEntity, fill up the columns that I want to change, and call the SaveMyEntity method in the BLL. This then has to fetch the persisted data, loop through the ent instance passed in as a parameter, set the values, and then persist that to the database.
OR
I could call a method in my manager class that is SaveEntity(string col1Value, string Col2Value, ... string ColnValue)
which would fetch the persisted data into a local entity, assign the values and save that data, BUT what if I add a column to the underlying table? I then have to make sure I go add a parameter to this save method.
OR
I could pass in an Hashtable with my column value pairs and loop through this inside of the BLL method and assign the values. That way, all my presentation layer has to do is send in the column value pairs that changed.
....what am I missing? These steps seem a bit involved. Am I missing a whole piece to this? Here are my assumptions about the datagrid:
1) Once rendered to the page, it loses all connections to the datasource that built it.
2) The only way to get at data on the screen is to interrogate the widgets that contain the displayed data (ie, textbox.Text and droplist.selectedValue)
3) I basically have to "start over" again when they click update because I have to go fetch my persisted data back into entities in order to operate against them.
...please help me understand if I'm missing some key element here.
P.S. I'm accostomed to dealing with a client/server environment so this whole stateless world is still strange and unhelpful to me.