Welcome Guest Search | Active Topics | Sign In | Register

How to restore the row status, such as IsAdded/IsChanged/IsDeleted, after callback Options
Bruce
Posted: Sunday, February 22, 2009 11:31:57 PM
Rank: Member
Groups: Member

Joined: 2/22/2009
Posts: 13
I put a Grid in web form. End user may add/change/delete grid items at client-side and then press "Save" button to callback. During the callback process, I do a validation checking in server side. For example, end user is not allowed to input duplicate account no. Now my question is if it is fail in validation checking at server side, then end user may correct the grid cell value and then press the save button again. However, at this moment, I can't get the changed/Added/Deleted items with the Grid Properties (e.g. Grid1.ChangedItems, Grid.AddedItems, Grid.DeletedItems). It seems that the Grid state is changed after callback. How can I restore it?
eo_support
Posted: Sunday, February 22, 2009 11:53:56 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,103
Hi,

You will not be able to restore the states once the page is posted back (Callback does post back too). For your situation, you can flag those items. The next time the page posts back, you can check all grid items and see which item has been flagged, you can then carry on additional actions based on the flags.

There are essentially two ways to flag the items. One way is to store the flags in your database. The other way is to store the flags in the Grid. If you store the flag in your database, you would have "submitted" items and "unsubmitted" items in your database. When the page posts back, all Grid.AddedItems will be written directly to the database, but for those that did not pass validation, it will be marked as "unsubmitted". The most important advantage of this approach is if user closes browser and then come back again later, they will be able to continue from where they left off, since everything is stored in the database.

The other way is to store the flag information in the Grid. Our latest build supports hidden column. So you can add a hidden column in the grid and use that column to store your flag information. When the page first posts back, you would mark all "AddedItems" by setting a flag in that hidden column. When the page posts back again, you would walk through all items and check the flag to see if this was an item to be added.

Both ways rely on the extra flag, so additional code will always be needed to set/clear the flag and carry out actions based on the flag value. The only difference between the two approaches is where you store the flag.

Hope this helps.

Thanks!
Bruce
Posted: Monday, February 23, 2009 1:07:36 AM
Rank: Member
Groups: Member

Joined: 2/22/2009
Posts: 13
Oh. Thanks. Let me try the new build package


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.