New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial

Provides data for Command events including CancelCommand, DeleteCommand, EditCommand, InsertCommand, ItemCommand, SortCommand and UpdateCommand.

Definition

Constructors

C#
public GridCommandEventArgs(GridItem item, object commandSource, CommandEventArgs originalArgs)
Parameters:itemGridItemcommandSourceobjectoriginalArgsCommandEventArgs

Properties

Gets or sets a value, defining whether the command should be canceled.

C#
public bool Canceled { get; set; }

Implements: IGridCommandEvent.Canceled

Example:
cs-api-definition
protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)
{
if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
{
GridEditFormItem item = e.Item as GridEditFormItem;
Hashtable newValues = new Hashtable();
item.OwnerTableView.ExtractValuesFromItem(newValues, item);
if (newValues["Name"].ToString() == "DefaultName")
{
e.Canceled = true;
}
}
}

Gets the source of the command

C#
public object CommandSource { get; }
Example:
cs-api-definition
// Get a reference to the control that triggered expand/collapse command
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.ExpandCollapseCommandName)
{
Control c = e.CommandSource as Control;
}
}

Gets the item containing the command source

C#
public GridItem Item { get; }
Example:
cs-api-definition
protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)
{
if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
{
GridEditFormItem item = e.Item as GridEditFormItem;
Hashtable newValues = new Hashtable();
item.OwnerTableView.ExtractValuesFromItem(newValues, item);
if (newValues["Name"].ToString() == "DefaultName")
{
e.Canceled = true;
}
}
}

Methods

Fires the command stored in CommandName property

C#
[SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
public virtual void ExecuteCommand(object source)
Parameters:sourceobject

Implements: IGridCommandEvent.ExecuteCommand(object)

C#
protected void SetCommandSource(object commandSource)
Parameters:commandSourceobject