[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Collapse]Grid View
   [Expand]Product Information
    Getting Started
    [Expand]Binding to Data
    [Expand]Data Representation Basics
    [Expand]Focus and Navigation
    [Collapse]Data Editing
      Edit Form
      Adding and Deleting Records
      Row Validation and Error Indication
      Edit Form Validation (Templates)
      Processing Custom Callbacks
      Batch Edit Mode
    [Expand]Data Shaping and Manipulation
    [Expand]Data Formatting
    [Expand]Master-Detail Relationship
     Appearance Customization
     Save and Restore Layout
    ASPxGridView Designer
   [Expand]Visual Elements
   [Expand]Member Tables
   [Expand]ASPxGridView - Animated Images
  [Expand]Tree List
  [Expand]Card View
  [Expand]Chart Control
  [Expand]Pivot Grid
  [Expand]Rich Text Editor
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Controls
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Adding and Deleting Records

Expanded Creating and Initializing New Rows

End-users can create new rows via the New command.

To allow end-users to add new rows, create a command column, access the New command's settings via the ASPxGridViewCommandButtonSettings.NewButton property and set the GridViewCommandColumnButton.Visible property to true.

To create rows in code, use the server ASPxGridView.AddNewRow or client ASPxClientGridView.AddNewRow method. These methods switch ASPxGridView to an edit mode and allow the values of the new row to be edited.

To initialize row values in code, handle the ASPxGridView.InitNewRow event.


In this example the ASPxGridView.InitNewRow event is handled to initialize the new record's field values with default values.

The image below shows the result:

Expanded Adding Rows

To add a new record to the underlying data source, call the ASPxGridView.UpdateEdit (or ASPxClientGridView.UpdateEdit) method. End-users can do this by clicking the Update command.

You can also implement row validation. For information, see Row Validation and Error Indication.

After a new row has been added to ASPxGridView, the ASPxGridView.RowInserted event is raised. To cancel the insert operation, handle the ASPxGridView.RowInserting event.

Expanded Deleting Rows

End-users can delete rows via the Delete command. To do this in code, use the server ASPxGridView.DeleteRow or client ASPxClientGridView.DeleteRow method.

After a row has been deleted, the ASPxGridView.RowDeleted event is raised. To cancel the delete operation, handle the ASPxGridView.RowDeleting event.

To allow an end-user to cancel the delete operation, enable the ASPxGridBehaviorSettings.ConfirmDelete option. In this case, when the user deletes a row, the Confirm Delete window is automatically displayed.

The text displayed within the Confirm Delete window can be specified via the ASPxGridTextSettings.ConfirmDelete property.



Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E3076.

The example illustrates how to delete selected rows of the ASPxGridView bound with an in-memory DataSource.

See Also:

How to move selected rows from the ASPxGridView into another ASPxGridView

Editing an in-memory dataset

Is this topic helpful?​​​​​​​