Skip to main content

Initializing New Cards

The CardView extension allows you to define the default field values displayed within the built-in edit form of the newly added records.

To initialize card values in code, define the initial values in the ASPxDataInitNewRowEventArgs.NewValues dictionary within a delegate method, and assign this delegate method to the CardViewSettings.InitNewCard property.

Example:

@Html.DevExpress().CardView(settings => {
    settings.Name = "CardView";

    // ...
    settings.KeyFieldName = "CategoryID";
    settings.Columns.Add("CategoryID");
    settings.Columns.Add("CategoryName");
    settings.Columns.Add("Description");
    // Process the initialization of new cards.
    settings.InitNewCard = (s, e) =>
    {
        e.NewValues["CategoryName"] = "Seafood";
        e.NewValues["Description"] = "Seafood and fish";
    };
}).Bind(Model).GetHtml()

The image below illustrates how the edit form will appear after an end-user clicks the New button.

ASPxCardView_InitNewCard