[Expand]General Information
[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
  [Collapse]Grid View
   [Expand]Product Information
    Getting Started
   [Expand]Fundamentals
   [Collapse]Concepts
    [Expand]Bind to Data
    [Expand]Data Representation Basics
    [Expand]Focus and Navigation
    [Collapse]Edit Data
      Edit and Add Records
      Delete Records
      Edit Form
      Batch Edit Mode
      Validate Grid Data
      Processing Custom Callbacks
    [Expand]Use Data Summaries
    [Expand]Filter Data
    [Expand]Group Data
    [Expand]Sort Data
     Merge Data Cells
     Save and Restore Client Layout
    [Expand]Format Data
    [Expand]Master-Detail Relationship
     Appearance Customization
     Adaptivity
     GridView Table Layout
    [Expand]Templates
    [Expand]Export
     Toolbars
    [Expand]ASPxGridLookup
    Grid Designer
   [Expand]Visual Elements
   [Expand]Examples
   [Expand]Member Tables
  [Expand]Tree List
  [Expand]Gantt
  [Expand]Card View
   Reporting
  [Expand]Chart Control
  [Expand]Pivot Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Scheduler
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Gauges
  [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]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]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Delete Records

This topic illustrates how to delete the ASPxGridView's records. Use the instructions below to manage records when the grid is in the Inline, EditForm, EditFormAndDisplayRow, and PopupEditForm edit modes (ASPxGridViewEditingSettings.Mode). Refer to the Batch Edit Mode topic for more information on how to delete records in batch edit mode.

Note

Expanded Create UI Element

Use any of the following UI elements that allow users to delete records:

The built-in Delete command button

Create a command column (GridViewCommandColumn) and use the GridViewCommandColumn.ShowDeleteButton property to display the Delete command button in the grid. Use the ASPxGridViewCommandButtonSettings.DeleteButton object to access the Delete command button's settings.

Custom UI element

Create custom UI elements that call the following APIs to delete records:

  • The ASPxGridView.DeleteRow method (server side).

  • The ASPxClientGridView.DeleteRow method (client side).

  • The DeleteRowByKey(key) method (client side).

Confirm Delete

Use the ASPxGridBehaviorSettings.ConfirmDelete property to specify whether the grid displays the delete confirmation dialog. The ASPxGridTextSettings.ConfirmDelete property specifies the delete confirmation dialog's text.

Expanded Client-Side Events

The grid sends a callback to the server and raises the BeginCallback and EndCallback events when you click a command button or call the DeleteRow(visibleIndex) or DeleteRowByKey(key) methods. You can handle the BeginCallback event and check the e.command property to determine which user action triggered a callback.

Note

Do not to send parallel callbacks to controls because it can cause unpredictable results (the controls may return callback results at a different time). Refer to the Concept of Callbacks help article for the recommended approach.

The following example illustrates how to use subsequent callbacks to create a new record after you deleted a row.

Expanded Server-Side Events

The grid raises the following server-side events when you delete a record:

  • The ASPxGridView.RowDeleting event. The grid raises this event when an end user attempts to remove the record. Set the e.Cancel argument to true to prevent this action.

    Note

    The grid raises the client-side BeginCallback and EndCallback events even if you set the event's e.Cancel property to true. You can use the ASPxGridBase.JSProperties property to pass information from the server side to the client.

  • The ASPxGridView.RowDeleted event occurs when the record is removed from the database.

Online Examples

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