This example demonstrates how you can implement the Multi-Row editing for ASPxGridViews in the Master-Detail scenario. The ASPxHiddenField control is used to store edited values and to send data to the server.
The advantages of this approach:
- the edited values will not be missing after the grid's callbacks (sorting, filtering, paging).
- in the datasource, only changed rows will be updated
The main idea of this approach is to put the ASPxHiddenField in the Title template, so it will be updated on all grid's callbacks, and its data will be accessible on GridView's events. Each DataItem editor has its own client-side ASPxClientEdit.ValueChanged event handler to save its data to the hidden field with a corresponding key based on the column's field name and row key value. When the "Apply Changes" button is pressed, a callback is sent to the server by calling the client-side ASPxClientGridView.PerformCallback method. In the server-side ASPxGridView.CustomCallback event handler, data is loaded from the hidden field and saved to the datasource.
See also:
The general technique of using the Init/Load event handler
How to create a DataItem template for a grid column at runtime
A simple example of master-detail grids with editing capabilities
How to implement the multi-row editing feature in the ASPxGridView
How to perform ASPxGridView instant updating using different editors in the DataItem template
Question Comments
Added By: Angela Pearman at: 1/17/2013 10:41:13 AM
I copied the code exactly from this sample. I imported the Nwind Db. But when I run it, edit a field, then hit 'apply changes' I get error 'Invalid key '1_productname'. Then when I click OK (only option), I get 'first character '1' in the property name "1_ProductName" is invalid. Property name can contain letters, digits, underline characters, and dollar signs. It can't begin with a digit character."
Added By: Angela Pearman at: 1/17/2013 11:02:35 AMok, I figured out the problem. In the class EditableDataItem I changed the fieldkey to string.Format("{1}_{0}". This puts the number at the end of the field name. It worked that way.
Added By: Paul.Astramowicz@thyssenkrupp.com Paul.Astramowicz@thyssenkrupp.com at: 8/28/2014 7:27:45 AMHello Support,
Is there any way you can try running this example using the latest version of DEvExpress in ASP.net? Just wondering if it will work. Version=14.1.5.0