Skip to main content

ASPxCardView.CardUpdating Event

Enables you to prevent a card from being updated.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v22.2.dll

NuGet Package: DevExpress.Web


public event ASPxDataUpdatingEventHandler CardUpdating

Event Data

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

Property Description
Cancel Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.
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 values of the non-key field name/value pairs in the row to be updated.
OldValues Gets a dictionary that contains the original field name/value pairs in the row to be updated.


The CardUpdating event occurs when an end-user has changed cell values and tries to pass them to the data source by clicking the Update command. To cancel the update operation, set the event parameter’s Cancel property to true.

If you use edit form templates, you must process the update manually in the CardUpdating event handler.

After a card has been updated, the ASPxCardView.CardUpdated event is raised.


The example illustrates how to delete selected cards of the ASPxCardView bound with an in-memory DataSource.

View Example

<head runat="server">
    <script type="text/javascript">
        function OnClickButtonDel(s, e) {
    <form id="form1" runat="server">
        <dx:ASPxCardView ID="ASPxCardView1" KeyFieldName="ID" AutoGenerateColumns="False" runat="server" OnCellEditorInitialize="ASPxCardView1_CellEditorInitialize" OnCardInserting="ASPxCardView1_CardInserting" OnCardUpdating="ASPxCardView1_CardUpdating" ClientInstanceName="card" OnCustomCallback="ASPxCardView1_CustomCallback" OnDataBinding="ASPxCardView1_DataBinding">
                <dx:CardViewTextColumn FieldName="ID" VisibleIndex="0">
                <dx:CardViewTextColumn FieldName="Data" VisibleIndex="1">
                    <dx:CardViewCommandLayoutItem HorizontalAlign="Right" ShowSelectCheckbox="True">
                    <dx:CardViewColumnLayoutItem ColumnName ="ID" >
                    <dx:CardViewColumnLayoutItem ColumnName="Data" >
                    <dx:EditModeCommandLayoutItem HorizontalAlign="Right">
        <dx:ASPxButton ID="ASPxButton1" runat="server" ClientInstanceName="btn1" AutoPostBack="false" Text="Delete">
            <ClientSideEvents Click="OnClickButtonDel"/>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Web;

public partial class _Default : System.Web.UI.Page
    DataTable table = null;
    protected void Page_Init(object sender, EventArgs e) {
        if (!IsPostBack && !IsCallback)
            table = new DataTable();
            table.Columns.Add("ID", typeof(int));
            table.Columns.Add("Data", typeof(string));
            table.PrimaryKey = new DataColumn[] { table.Columns["ID"] };
            for (int i = 0; i < 10; i++)
                table.Rows.Add(new object[] { i, "row " + i.ToString() });
            Session["table"] = table;
            table = (DataTable)Session["table"];
    protected void Page_Load(object sender, EventArgs e) {
        if (!IsCallback && !IsPostBack) ASPxCardView1.DataBind();
    protected void ASPxCardView1_CellEditorInitialize(object sender, DevExpress.Web.ASPxCardViewEditorEventArgs e) {
        ASPxCardView grid2 = (ASPxCardView)sender;
        if (e.Column.FieldName == "ID")
            ASPxTextBox textBox = (ASPxTextBox)e.Editor;
            textBox.ClientEnabled = false;
            if (grid2.IsNewCardEditing)
                table = (DataTable)Session["table"];
                textBox.Text = GetNewId().ToString();
    protected void ASPxCardView1_CardInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) {
        table = (DataTable)Session["table"];
        ASPxCardView cv = (ASPxCardView)sender;
        DataRow row = table.NewRow();
        row["ID"] = e.NewValues["ID"];
        row["Data"] = e.NewValues["Data"];
        e.Cancel = true;
    protected void ASPxCardView1_CardUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) {
        table = (DataTable)Session["table"];
        DataRow row = table.Rows.Find(e.Keys[0]);
        row["Data"] = e.NewValues["Data"];
        e.Cancel = true;

    protected void ASPxCardView1_DataBinding(object sender, EventArgs e) {
        ASPxCardView1.DataSource = table;
    #region #CustomCallbackMethod
    protected void ASPxCardView1_CustomCallback(object sender, DevExpress.Web.ASPxCardViewCustomCallbackEventArgs e) {
        if (e.Parameters == "Delete")
            table = (DataTable)Session["table"];
            List<Object> selectItems = ASPxCardView1.GetSelectedFieldValues("ID");
            foreach (object selectItemId in selectItems)
    #endregion #CustomCallbackMethod
    private int GetNewId() {
        table = (DataTable)Session["table"];
        if (table.Rows.Count == 0) return 0;
        int max = Convert.ToInt32(table.Rows[0]["ID"]);
        for (int i = 1; i < table.Rows.Count; i++)
            if (Convert.ToInt32(table.Rows[i]["ID"]) > max)
                max = Convert.ToInt32(table.Rows[i]["ID"]);
        return max + 1;
See Also