[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]ASP.NET WebForms Controls
 [Collapse]ASP.NET MVC Extensions
  [Expand]Product Information
  [Expand]Getting Started
  [Expand]Common Concepts
  [Collapse]Grid View
    Main Features
   [Collapse]Concepts
    [Expand]Binding to Data
    [Collapse]Data Representation Basics
     [Expand]Cells
     [Collapse]Columns
       Data Columns
       Command Column
       Band Columns
       Unbound Columns
       Fixed Columns
     [Expand]Rows
      Customization Window
    [Expand]Data Shaping and Manipulation
    [Expand]Focus and Navigation
    [Expand]Data Editing and Validation
    [Expand]Exporting
   [Expand]Visual Elements
   [Expand]Member Tables
   [Expand]Examples
  [Expand]Tree List
  [Expand]Card View
   Reporting
  [Expand]Charting
  [Expand]Pivot Grid
   Spreadsheet
   Rich Text Editor
  [Expand]Scheduler
  [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 Extensions
  [Expand]Spell Checker
  [Expand]Query Builder
 [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)

Command Column

End-users can manipulate ASP.NET MVC GridView data via a command column. You can access command column settings via the GridViewSettings.CommandColumn property.

Expanded Commands

A Command Column is represented by the MVCxGridViewCommandColumn class. It provides a set of commands that allows end-users to switch the GridView to edit mode, and update data, delete rows, etc.

A command column allows multiple command items to be displayed within a cell. A single command is represented by a Command Item. There are eight command items.

Command

Description

Settings

Visibility

New

Creates a new data row.

ASPxGridViewCommandButtonSettings.NewButton

GridViewCommandColumn.ShowNewButton,

GridViewCommandColumn.ShowNewButtonInHeader

Edit

Switches the GridView to edit mode.

ASPxGridViewCommandButtonSettings.EditButton

GridViewCommandColumn.ShowEditButton

Delete

Deletes the current data row.

ASPxGridViewCommandButtonSettings.DeleteButton

GridViewCommandColumn.ShowDeleteButton

Select

Selects/deselects data rows.

ASPxGridViewCommandButtonSettings.SelectButton

GridViewCommandColumn.ShowSelectButton,

GridViewCommandColumn.ShowSelectCheckbox

Update

Saves all changes made to the current data row and switches the GridView to browse mode.

ASPxGridViewCommandButtonSettings.UpdateButton

GridViewCommandColumn.ShowUpdateButton

Cancel

Discards any changes made to the current data row and switches the GridView to browse mode.

ASPxGridViewCommandButtonSettings.CancelButton

GridViewCommandColumn.ShowCancelButton

Clear

Clears the filter expression applied to the GridView.

ASPxGridViewCommandButtonSettings.ClearFilterButton

GridViewCommandColumn.ShowClearFilterButton

Recover

Recovers a deleted data row.

ASPxGridViewCommandButtonSettings.RecoverButton

GridViewCommandColumn.ShowRecoverButton

By default, command items are represented by a link. They can also be represented by a button or image. Use the GridViewCommandColumn.ButtonType (via GridViewSettings.CommandColumn.ButtonType) property to specify how the command column renders its command items.

Example

The example below shows how to enable a command column with command buttons. In this example, the "New" button is placed within the column header and is represented as an image.

Partial View code:

The image below illustrates the result.

Expanded Behavior

End-users can move the command column to a different position within the grid (in relation to the other visible columns) or to the Customization Window by dragging its header. This is controlled by the column's GridViewCommandColumn.AllowDragDrop (via GridViewSettings.CommandColumn.AllowDragDrop) property. If this property is set to Default, the column behavior is controlled by the GridView's ASPxGridViewBehaviorSettings.AllowDragDrop (via GridViewSettings.SettingsBehavior.AllowDragDrop) option.

Expanded Custom Buttons

Command columns can display custom buttons within command cells. You can create your own buttons, and define custom actions for them.

Example

The example below shows how to create custom command buttons and define custom actions for them.

Controller code:

Partial View code ("_GridViewPartial"):

The image below illustrates the result.

Expanded See Also

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