Skip to main content
Tab

ASPxCardView.EnableCardsCache Property

Gets or sets whether data caching is enabled.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

[DefaultValue(true)]
public bool EnableCardsCache { get; set; }

Property Value

Type Default Description
Boolean true

true, to enable data caching; otherwise, false.

Remarks

By default, the ASPxCardView stores data in memory for quick access. This avoids repeated database calls when performing various operations that don’t require reloading data (e.g., rearranging or hiding columns). As a result, this increases the Web application scalability.

To disable data caching, set the EnableCardsCache option to false. This can be useful in the following cases:

  • The ASPxCardView displays real-time data.
  • Binding the ASPxCardView control to data created at runtime. The card view always reloads data from the server when you call the DataBind() method.
  • The ASPxCardView control uses the CardViewBinaryImageColumn. Setting the EnableCardsCache property to false reduces web page loading time.

Note

If you use custom objects that utilize a referenced association, the ASPxCardView tries to cache references as well. The serialization of a custom object is performed by the ToString method and is performed smoothly. But the object deserialization (restoration from String to object) could be raised with an exception:

TypeConverter cannot convert from System.String.

One solution is to turn off the ASPxCardView.EnableCardsCache property. This solution is acceptable when the page doesn’t have several grids, and in most cases, this doesn’t affect page performance significantly.

However, you can implement a custom TypeConverter derived class that can convert from the String type correctly. To learn more, see the Code Central example: How to implement a custom TypeConverter class for an XPO object

Example

The following example demonstrates how to show a complex property value in DataItemTemplate of a column that uses BindingExpressions.

<dx:aspxcardview ID="ASPxCardView1" AutoGenerateColumns="False"  EnableCardsCache="False" runat="server" DataSourceID="ObjectDataSource1" KeyFieldName="Id">
    <SettingsBehavior AllowFocusedCard="True" />
    <Columns>
        <dx:CardViewTextColumn FieldName="Id" VisibleIndex="0" Width="10%">
        </dx:CardViewTextColumn>
        <dx:CardViewTextColumn FieldName="Name" VisibleIndex="1" Width="30%">
        </dx:CardViewTextColumn>
        <dx:CardViewTextColumn Caption="Street" FieldName="Address" VisibleIndex="2" Width="30%">
            <DataItemTemplate>
                <dx:ASPxTextBox ID="ASPxTextBox1" runat="server" Text='<%# Eval("Address.Street") %>' Width="100%"></dx:ASPxTextBox>
            </DataItemTemplate>
        </dx:CardViewTextColumn>
        <dx:CardViewTextColumn Caption="City" FieldName="Address" VisibleIndex="3" Width="33%">
            <DataItemTemplate>
                <dx:ASPxTextBox ID="ASPxTextBox2" runat="server" Text='<%# Eval("Address.City") %>' Width="100%"></dx:ASPxTextBox>
            </DataItemTemplate>
        </dx:CardViewTextColumn>
    </Columns>
</dx:aspxcardview>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="SelectData" TypeName="Person">
</asp:ObjectDataSource>    
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

public class Person {
    private int id;
    private string name;
    private Address address;

    public Person() {

    }
    public Person(int id, string name, Address address) {
        this.id = id;
        this.name = name;
        this.address = address;
    }

    public int Id { get{ return id; } }
    public string Name { get{ return name; } }
    public Address Address { get{ return address; } }

    public List<Person> SelectData() {
        List<Person> persons = new List<Person>();
        persons.Add(new Person(0, "John", new Address("Home Lane", "Homesville")));
        persons.Add(new Person(1, "Henry", new Address("436 1st Ave", "Cleveland")));
        return persons;
    }
}

public class Address {
    string street;
    string city;
    public Address(string street, string city) {
        this.street = street;
        this.city = city;
    }

    public string Street { get { return street; } }
    public string City { get { return city; } }}
See Also