Tab
A newer version of this page is available. Switch to the current version.

GridViewCommandColumn.CustomButtons Property

Gets the collection of custom buttons.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v18.2.dll

Declaration

[DefaultValue(null)]
public GridViewCommandColumnCustomButtonCollection CustomButtons { get; }
<DefaultValue(Nothing)>
Public ReadOnly Property CustomButtons As GridViewCommandColumnCustomButtonCollection

Property Value

Type Default Description
GridViewCommandColumnCustomButtonCollection

null

A GridViewCommandColumnCustomButtonCollection object which represents the collection of custom buttons.

Remarks

Command columns can display custom buttons. You can create your own buttons, and define custom actions for them by handling the ASPxGridView.CustomButtonCallback event.

Example

WebForms:

<dx:ASPxGridView ID="grid" runat="server" DataSourceID="DemoDataSource1" KeyFieldName="EmployeeID" 
AutoGenerateColumns="False" OnCustomButtonCallback="grid_CustomButtonCallback" ...>
    <Columns>
        <dx:GridViewCommandColumn ShowNewButton="true" ShowEditButton="true" VisibleIndex="0" ButtonRenderMode="Image">
            <CustomButtons>
                <dx:GridViewCommandColumnCustomButton ID="Clone">
                    <Image ToolTip="Clone Record" Url="Images/clone.png" />
                </dx:GridViewCommandColumnCustomButton>
            </CustomButtons>
        </dx:GridViewCommandColumn>
        ...
    </Columns>
</dx:ASPxGridView>

MVC:

using System;
using System.Collections.Generic;
using System.Web.Mvc;
using MyProject.Models;
namespace MyProject.Controllers
{
    public class HomeController : Controller
    {
        // ... 
        // "gridItems()" returns a list of records displayed within a GridView. 
        // Handle the custom callback. 
        public ActionResult CustomButtonClick(string clickedButton)
        {
            // Show a different number of records depending on the ID of the custom button that was clicked. 
            if (clickedButton == "First10") { 
                return PartialView("_GridViewPartial", gridItems().GetRange(0, 10)); 
            }
            else {
                return PartialView("_GridViewPartial", gridItems().GetRange(0, 5) );
            }
        }
    }
}

Online Demo

ASPxGridView - Custom Command Buttons

See Also