This is a migrated thread and some comments may be shown as answers.

How to get the bound entity of editing record in UpdateCommand event

5 Answers 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jin
Top achievements
Rank 1
Jin asked on 02 Sep 2012, 08:39 AM
How to get the bound entity of editing record in UpdateCommand event? For example, I bound a List<Customer> to a RadGrid, when I clicking save button to fire the RadGridFunction_UpdateCommand event, I have no way to get the Customer entity of editing record. Because I don't want to retrieve the record based on current primary key from DB, I only want to get from bound source.

5 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 03 Sep 2012, 07:54 AM
0
Jin
Top achievements
Rank 1
answered on 03 Sep 2012, 08:42 AM
Hi,

The post cannot fix my problem. I want to get the bound entity class instead of updated value in hashtable.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 03 Sep 2012, 10:28 AM
Hello,

sorry but we can not get bound entity in insert/update/delete commnad/event.

You can only get bound entity in itemdatabound event.

Thanks,
Jayesh Goyani
0
Jin
Top achievements
Rank 1
answered on 03 Sep 2012, 12:46 PM
I check your sample code. In updateing event, you will retrieve the entity class from DB first based on edited record primary key, then call e.item.UpdateValues to update the entity class, then call Context method to update record to DB. I think the good way is that get the bound entity instead of get it from DB again. It have two advantages:
1.Get more performance due to reduce one DB calling.
2.Easy to prompt user information while the concurrent updating.Because after one record to be bound in GridView, it will have a version_no field to be indicated.After user edit the record, if we can get version_no field from bound record, we can easy to check the concurrent operation in DB based on comparing the passed version_no field and the latest value in DB.
0
Andrey
Telerik team
answered on 06 Sep 2012, 10:15 AM
Hello,

You could check this online resource which gives more information on how to use concurrency with Entity Framework.

Greetings,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Jin
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Jin
Top achievements
Rank 1
Andrey
Telerik team
Share this question
or