Saving Entity from DataGrid on Update - Part 2

Posts   
 
    
NickD
User
Posts: 224
Joined: 31-Jan-2005
# Posted on: 16-Dec-2005 18:49:15   

I posted this originally here http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=4968

...and bclubb gave me his opinion, but I was hoping to get some other feedback as well and the marked the thread as complete. If any Support Team people answer this one, maybe you could leave it open until I get some more feedback from others. Thanks...

vvvvvvvvvvvvvvvv Original post vvvvvvvvvvvvvvvv

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.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 16-Dec-2005 19:07:31   

You can add a posting to a 'done' marked thread and it will be marked 'not done' automatically. I marked it as done because I thought your question was answered. if you want me to open it again, no problem, and I'll then close this thread. I've bookmarked your other thread and will try to answer it tomorrow.

Frans Bouma | Lead developer LLBLGen Pro
NickD
User
Posts: 224
Joined: 31-Jan-2005
# Posted on: 16-Dec-2005 20:26:29   

Otis wrote:

You can add a posting to a 'done' marked thread and it will be marked 'not done' automatically. I marked it as done because I thought your question was answered. if you want me to open it again, no problem, and I'll then close this thread. I've bookmarked your other thread and will try to answer it tomorrow.

Good thinking too on the "auto mark as undone." I'll just post to the original one and reopen it. You can delete this one or whatever you want to do.

Edit - BTW, Aren't Saturdays meant for forgetting what you did during the week? Not that I'm discouraging you from answering my question, I just don't want you to get burned out stuck_out_tongue_winking_eye

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 16-Dec-2005 21:23:18   

I try to do other things during the weekend, but at a small ISV, weekends aren't really existing. It's ok, I love my job simple_smile

Frans Bouma | Lead developer LLBLGen Pro