Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]Welcome to DevExpress .NET Documentation
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Reporting
  [Expand]Chart Control
  [Collapse]Grid View
   [Expand]Product Information
    Getting Started
   [Expand]Fundamentals
   [Collapse]Concepts
    [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
     Adaptivity
     Save and Restore Layout
    [Expand]Templates
    [Expand]Export
     Toolbars
    [Expand]ASPxGridLookup
    ASPxGridView Designer
   [Expand]Visual Elements
   [Expand]Examples
   [Expand]Member Tables
   [Expand]ASPxGridView - Animated Images
  [Expand]Card View
  [Expand]Vertical Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Image and Data Browsing
  [Expand]Docking and Popups
  [Expand]Site Navigation and Layout
  [Expand]File Management
  [Expand]Multi-Use Site Controls
  [Expand]Scheduler
  [Expand]HTML Editor
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gauges
  [Expand]Data Editors
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Localization
 [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]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[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.

Example:

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.

 

Example:

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?​​​​​​​