Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to implement the multi-row editing feature in the ASPxGridView

$
0
0

UPDATED:

Starting with version 13.2, the ASPxGridView control offers the basic "Batch Editing Mode" functionality that allows accomplishing a similar task with less effort and does not require so much extra code. See the ASP.NET WebForms & MVC: GridView Batch Edit blog post to learn more about this new functionality.

Starting with version 14.1, the ASPxGridView control offers advanced "Batch Editing Mode" programming options.

You can find a standalone DB-independent solution in our Code Examples base at:
ASPxGridView - A simple Batch Editing implementation

If you have version v14.1+ available, consider using the built-in functionality instead of the approach detailed below.
If you need further assistance with this functionality, please create a new ticket in our Support Center.

We already have the E158 example showing how to implement a similar feature. The project below is a simplified version of the same functionality, which allows you to edit all rows on a current page at once. To implement this, I added the ASPxTextBox to the DataItemTemplate Container of several columns and bound these editors to the underlying data source. This will force the ASPxGridView to always display editors in these columns. So, the end-user can input values in these editors. After that click the PostModifications button to preserve the changes made. NOTE, this is done without switching the ASPxGridView to the EditMode and back.

To preserve the changes made, I saved editor values to the List<object> and then used these values by setting the UpdateParameters of the ASPxGridView's DataSource. Finally, to obtain editors and their values, I used the ASPxGridView.FindRowCellTemplateControl Method.

See Also:
How to implement the multi-edit functionality with a multi-page grid that is bound dynamically
Custom client-side logic implementation in the grid with multi-row editing
How to edit multiple selected rows in a single Edit Form
How to force the grid to stay in Edit mode
How to perform ASPxGridView instant updating using different editors in the DataItem template

Question:E324 - How to calculate the ASPxGridView group summaries on the client side

Question Comments

Added By: jdubeau at: 7/17/2012 5:50:48 PM    

this example does update anything.

Added By: Wendy Ramsaur at: 7/23/2012 12:57:07 PM    

How are you collecting updated information and putting it in to the list? This only updates with the original information.

Added By: yaniv abo at: 7/25/2012 11:16:17 AM    

whan you select Run Online the Grid data does not update whan you click "Post Modifications"

Added By: Manish Singh 8 at: 7/30/2012 11:43:03 PM    

@yaniv abo : you have to provide the KeyFieldName Properties of gridview then this code will work

Added By: Wendy Ramsaur at: 7/31/2012 10:34:47 AM    

OK, it works...sort of. I have a column represented by a RadioButtonList. The callback is not getting any updated values. Can I get some help?

Added By: Wendy Ramsaur at: 7/31/2012 10:45:12 AM    

Also just tried using a textbox. Again, does not get updated values in this example.

Added By: Fiona Titcombe at: 10/18/2012 4:00:21 AM    

Is there any solution to this? FindRowCellTemplateControl(grid, col, "txtBox") returns the original value, not the updated value.

Added By: Hamdy Nassar at: 10/20/2012 12:44:48 AM    

thanks alot it is working perfect

Added By: Steve Knowles at: 12/10/2012 10:16:11 AM    

I am having the same problem as others in that the original, not updated value is being returned. Has anyone figured out why this happens in some projects?

Added By: Ashley Perkins at: 12/18/2012 9:02:33 AM    

To anyone having problems with this demo make sure you are not touching the grid view data source on page load.

I was changing the select query and rebinding on page load, this caused the values to reset. Got rid of that and it worked perfectly.

Added By: Bryan Meier at: 1/31/2013 11:36:43 AM    

To add on to what Ashley commented on...

Make sure you have the AutoPostBack set to false on the button you are using to perform the callback. By default the value is true which will override your callback and the OnCustomCallback event of your grid will never get called. Not to mention your changes will be reverted back to the original values.

Added By: Prashanthi G at: 9/3/2013 9:19:25 PM    

In this given example no.of rows is less and it is working fine, how to achieve this kind of functionality if more no of records more say for ex 100 records. page load became very slow and some times not responding message is coming. Any suggessions

Added By: Philippe Foucart at: 9/24/2013 2:18:37 AM    

Works perfect for me on pc, but not on ipad -> on ipad, when clicking the button, nothing happens, I just get the circling image indicating somethings happening in background, but looks like callback is not executed.
any ideas?

Added By: Richard Wilke at: 11/10/2013 3:10:37 PM    

I have converted this code to fit my database structure. It looks like everything is coded correctly, but after running through the code to update the database ...

 for (int i = 0; i < list.Count; i++) {
                AccessDataSource1.UpdateParameters["CategoryName"].DefaultValue = list[i].CategoryName;
                AccessDataSource1.UpdateParameters["Description"].DefaultValue = list[i].Description;
                AccessDataSource1.UpdateParameters["CategoryID"].DefaultValue = list[i].Id.ToString();
// AccessDataSource1.Update(); << Uncomment this line to update data!
            }
            ASPxGridView1.DataBind();

The database never gets updated. Any thoughts? The list gets built correctly and contains all the updated data from the grid. Help.

Added By: M Abo Habiba at: 1/6/2014 1:55:28 AM    

Is this resolved 13.2 as BatchEdit ?

Added By: Paul.Astramowicz@thyssenkrupp.com Paul.Astramowicz@thyssenkrupp.com at: 8/13/2014 12:48:28 PM    

Can we use this Example somehow but within using it within a FORM<>  ???

Added By: Artem (DevExpress Support) at: 8/13/2014 11:17:10 PM    

Hello Paul,

To process your recent post more efficiently, I created a separate ticket on your behalf: T140120: E324 - Using within a form. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>