RadGrid for ASP.NET

RadGrid Send comments on this topic.
CancelCommand Event
See Also  Example
Telerik.WebControls Namespace > RadGrid Class : CancelCommand Event


Occurs when the Cancel button is clicked for an item in the Telerik RadGrid control.

 

Example


The following code example demonstrates how to specify and code a handler for the CancelCommand event to cancel edits made to an item in the Telerik RadGrid control.  
 

 

Namespace: Telerik.WebControls
Assembly: RadGrid (in RadGrid.dll)

Syntax

Visual Basic (Declaration) 
Public Event CancelCommand() As GridCommandEventHandler
Visual Basic (Usage)Copy Code
Dim instance As RadGrid
Dim handler As GridCommandEventHandler
 
AddHandler instance.CancelCommand, handler
C# 
public event GridCommandEventHandler CancelCommand()
 

Example


The following code example demonstrates how to specify and code a handler for the CancelCommand event to cancel edits made to an item in the Telerik RadGrid control.
Visual BasicCopy Code
<%@ Page Language="VB" <see cref="!:> <"/>@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Protected Sub RadGrid1_CancelCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridCommandEventArgs)
        Response.Write("Cancel")
    End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <rad:RadGrid
            DataSourceID="SqlDataSource1"
            ID="RadGrid1"
            runat="server" OnCancelCommand="RadGrid1_CancelCommand" >
            <MasterTableView>
                <Columns>
                    <rad:GridEditCommandColumn>
                    </rad:GridEditCommandColumn>
                </Columns>
            </MasterTableView>
        </rad:RadGrid>
        <!-- This example uses Microsoft SQL Server and connects -->
        <!-- to the Northwind sample database. Use an ASP.NET -->
        <!-- expression to retrieve the connection string value -->
        <!-- from the Web.config file. -->
        <asp:SqlDataSource
            ID="SqlDataSource1"
            runat="server"
            ConnectionString="<<see cref="!:NorthwindConnectionString">$ ConnectionStrings</see>>"
            SelectCommand="SELECT TOP 5 [CustomerID], [ContactName], [CompanyName] FROM [Customers]">
        </asp:SqlDataSource>
    </div>
    
</body>
</html>

Remarks

The CancelCommand event is raised when the Cancel button is clicked for an item in the Telerik RadGrid control.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also