Ok, here you are.
Attached is a file containing code that needs to be added to your FormUtil.cs that resides in the web project.
As I previously posted in another thread, I found that using the entitydatasource (EDS) and strongly typd data source controls (STDS) did not handle concurrency checking when only using a timestamp field. I think the reason is that the timestamp field is not maintained between postbacks. Typically you wouldn't put that sort of field on a screen anyhow (it can be done but its a bit messy) so my work around is to do the following:
1. Use the DataKeyNames of the gridview/formview to store the timestamp value across postbacks. This doesn't seem to have any adverse affects with regards to what the actual keys are (indeed I've seen a post from a microsoft person suggesting using the datakeynames for a similar purpose).
2. However, the EDS & STDS need to be passed the timestamp field so it can check whether its changed using the underlying stored proc. So in the gridview/formview update event the timestamp field needs to be moved from the DataKeyNames to the NewValues.
The above would be enough for NetTiers to raise an exception when a concurrency issue had occurred. But thats not good enough is it?
3. It would be really cool if we automatically give the users feedback on what happened. So I've also included some methods that try to figure out what went wrong. So far I've added code for checking :
Concurrency exception (gives a user friendly message),
SQL exceptions (handles things like connectivity and constraint problems) and
entity errors (any broken rules messages).
This feedback is done by creating custom validators for the appropriate controls and assuming you have a validationsummary control on your form you should see appropriate messages.
All of the above is wrapped up into one neat call (overloads available) which you need to place in your Page_Load method...
FormUtil.HandleGridView( GridView1, "ConcurrencyTimeStamp" ); // for a gridview (or EntityGridView)
or
FormUtil.HandleFormView( FormView1, "ConcurrencyTimeStamp" ); // for FormView
Where "ConcurrencyTimeStamp" is the name of your timestamp field.
I hope it works for you. If it does perhaps it could be included in the NetTiers build?
Enjoy!
swin
PS. Some of the code is based on work done by Meech (I think), but I've beefed it up and adapted it for my own use.
-------------------------------------------------
Member of the .NetTiers team
-------------------------------------------------