Skip to main content
A newer version of this page is available. .
Tab

ASPxCardView.CardUpdated Event

Occurs after a card has been updated.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v18.2.dll

Declaration

public event ASPxDataUpdatedEventHandler CardUpdated

Event Data

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

Property Description
AffectedRecords Gets the number of records affected by the update operation. Inherited from ASPxDataBaseUpdatedEventArgs.
Exception Gets the exception (if any) that was raised during the update operation. Inherited from ASPxDataBaseUpdatedEventArgs.
ExceptionHandled Gets or sets whether an exception raised during the update operation was handled in the event handler. Inherited from ASPxDataBaseUpdatedEventArgs.
Keys Gets a dictionary of field name/value pairs that represent the primary key of the row to update.
NewValues Gets a dictionary that contains the updated values of the non-key field name/value pairs in the row.
OldValues Gets a dictionary that contains the original field name/value pairs for the updated record.

Remarks

The CardUpdated event occurs after the card with modified cell values has been updated. End-users can update cards by clicking the Update command. To cancel the update operation, handle the ASPxCardView.CardUpdating event.

Note

The CardUpdated event fires even though an exception occurs during the data update operation. Use the ASPxDataBaseUpdatedEventArgs.Exception and ASPxDataBaseUpdatedEventArgs.ExceptionHandled argument properties to determine whether or not any exception occurs during the corresponding action, and handle it if you wish.

Example

By default, the ASPxCardView works during callbacks and there’s no way to update an external control (that isn’t a child control of the callback owner) on the server side.

The following article describes this limitation in detail: The Concept of Callbacks

This example covers both the JSProperties feature of the ASPxCardView that allows passing a value from the server to the client and the client-side ASPxClientCardView.EndCallback event, which is raised each time a callback is executed successfully. It is possible to set a JSProperty on the server, get it on the EndCallback, and change the “target” control using its client-side capabilities. This example illustrates how to use the ASPxLabel to identify that the grid was successfully updated.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register assembly="DevExpress.Web.v15.1, Version=15.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web" tagprefix="dx" %>


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

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <dx:aspxlabel ID="ASPxLabel1" runat="server" ClientInstanceName="clientLabel">
    </dx:aspxlabel>
    <dx:ASPxCardView ID="ASPxCardView1" runat="server" AutoGenerateColumns="false" DataSourceID="AccessDataSource1" KeyFieldName="CategoryID" OnCardUpdated="ASPxCardView1_CardUpdated">
        <clientsideevents EndCallback="function(s, e) {
            if (s.cpIsUpdated != '') {
                clientLabel.SetText('The category '+s.cpIsUpdated+' is updated successfully');
                clientLabel.GetMainElement().style.backgroundColor = 'green';
                clientLabel.GetMainElement().style.color = 'white';
            }
            else {
                clientLabel.SetText('');
            }
         }" />
        <Columns>
            <dx:CardViewColumn FieldName="CategoryID" ReadOnly="true" />
            <dx:CardViewColumn FieldName="CategoryName" ReadOnly="true"/>
            <dx:CardViewColumn FieldName="Description" ReadOnly="true"/>
        </Columns>
        <CardLayoutProperties>
            <Items>
                <dx:CardViewCommandLayoutItem ShowEditButton="true" HorizontalAlign="Right" />
                <dx:CardViewColumnLayoutItem ColumnName="CategoryID" />
                <dx:CardViewColumnLayoutItem ColumnName="CategoryName" />
                <dx:CardViewColumnLayoutItem ColumnName="Description" />
                <dx:EditModeCommandLayoutItem HorizontalAlign="Right" />
            </Items>
        </CardLayoutProperties>
    </dx:ASPxCardView>    
    <asp:accessdatasource ID="AccessDataSource1" runat="server" 
        DataFile="~/App_Data/nwind.mdb" 
        DeleteCommand="DELETE FROM [Categories] WHERE [CategoryID] = ?" 
        InsertCommand="INSERT INTO [Categories] ([CategoryID], [CategoryName], [Description], [Picture]) VALUES (?, ?, ?, ?)" 
        SelectCommand="SELECT * FROM [Categories]" 
        UpdateCommand="UPDATE [Categories] SET [CategoryName] = ?, [Description] = ?, [Picture] = ? WHERE [CategoryID] = ?">
        <deleteparameters>
            <asp:parameter Name="CategoryID" Type="Int32" />
        </deleteparameters>
        <updateparameters>
            <asp:parameter Name="CategoryName" Type="String" />
            <asp:parameter Name="Description" Type="String" />
            <asp:parameter Name="Picture" Type="Object" />
            <asp:parameter Name="CategoryID" Type="Int32" />
        </updateparameters>
        <insertparameters>
            <asp:parameter Name="CategoryID" Type="Int32" />
            <asp:parameter Name="CategoryName" Type="String" />
            <asp:parameter Name="Description" Type="String" />
            <asp:parameter Name="Picture" Type="Object" />
        </insertparameters>
    </asp:accessdatasource>        
    </form>
</body>
</html>
See Also