New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

InsertCommand Event

Fired when the Insert button is clicked for an item in the RadGrid control.

Event Parameters

  • (object) sender

    • The control that fires the event
  • (GridCommandEventArgs) e

    • Event arguments that

      • (boolean) e.Canceled

        If set to True the event will be canceled

      • (object) e.CommandArgument

        Arguments that are set to the Control's CommandName property. (Usually Button but it could be other Control in the Template)

      • (string) e.CommandName

        Name defined in the CommandName property of the Control.

      • (object) e.CommandSource

        The Control that fired the Command for the Grid.

      • (GridItem) e.Item

        Gets the Item containing the command source. Can be any of the Grid items that Inherit the GridItem class (e.g. GridDataItem, GridCommandItem, GridHeaderItem, GridFilteringItem, GridEditFormItem, etc...)

Attaching the event

In the Markup

ASP.NET
<telerik:RadGrid ID="RadGrid1" runat="server" OnInsertCommand="RadGrid1_InsertCommand">
</telerik:RadGrid>

In the Code behind

C#
protected void Page_Init(object sender, EventArgs e)
{
    RadGrid1.InsertCommand += RadGrid1_InsertCommand;
}

The event handler

C#
protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
{
    object commandArguments = e.CommandArgument;
    bool canceled = e.Canceled;
    string commandName = e.CommandName;
    object source = e.CommandSource;
    GridItem item = e.Item;
}

See Also