Back to Devexpress

ASPxGridView.HtmlCommandCellPrepared Event

aspnet-devexpress-dot-web-dot-aspxgridview-025dad55.md

latest3.9 KB
Original Source

ASPxGridView.HtmlCommandCellPrepared Event

Enables the settings of individual command column cells to be changed.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public event ASPxGridViewTableCommandCellEventHandler HtmlCommandCellPrepared
vb
Public Event HtmlCommandCellPrepared As ASPxGridViewTableCommandCellEventHandler

Event Data

The HtmlCommandCellPrepared event's data class is ASPxGridViewTableCommandCellEventArgs. The following properties provide information specific to this event:

PropertyDescription
CellGets the processed command cell.
CommandCellTypeGets whether the processed command cell is displayed within the auto filter row or data row.
CommandColumnGets a command column whose cell is currently being processed.
KeyValueGets an object that uniquely identifies the data row. Inherited from ASPxGridViewItemEventArgs.
VisibleIndexGets the visible index of the data row. Inherited from ASPxGridViewItemEventArgs.

Remarks

The HtmlCommandCellPrepared event is raised for each cell within command columns when the corresponding table cell is created. You can handle this event to change the style settings of individual command cells.

The processed cell is identified by the event parameter’s ASPxGridViewTableCommandCellEventArgs.Cell property. The column and row where the processed cell resides can be obtained via the ASPxGridViewTableCommandCellEventArgs.CommandColumn and ASPxGridViewItemEventArgs.KeyValue properties.

Example

aspx
<dx:ASPxGridView ClientInstanceName="gv" ID="ASPxGridView1" runat="server" OnHtmlCommandCellPrepared="ASPxGridView1_HtmlCommandCellPrepared" 
  AutoGenerateColumns="False" DataSourceID="SqlDataSource1" KeyFieldName="ProductID">
    <Columns>
        <dx:GridViewCommandColumn ShowDeleteButton="True" ShowEditButton="True" ShowNewButtonInHeader="True" VisibleIndex="0">
        </dx:GridViewCommandColumn>
        ...
    </Columns>
</dx:ASPxGridView>
csharp
protected void ASPxGridView1_HtmlCommandCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableCommandCellEventArgs e)
{
    e.Cell.BackColor = System.Drawing.Color.LightCyan;
}

Result:

See Also

Grid View

ASPxGridView Class

ASPxGridView Members

DevExpress.Web Namespace