This demo illustrates how to bind CardView columns to Model fields using lambda expressions.
To enable binding CardView columns to Model fields using lambdas, you must declare the CardView extension using the ExtensionsFactory.CardView<CardType> strongly-typed declaration method. This method accepts the CardViewSettings<CardType> object that implements the following specific strongly-typed members.
KeyFields.This method defines a key field (or multiple fields for a composite key). In this demo, the key field name is defined using the lambda expression passed as a parameter to the KeyFields method.
Columns. This property provides access to a collection of strongly-types columns. This collection exposes the specific Add method that accepts the lambda expression that defines a particular model field to which the newly created column will be bound.
The specific Add method overload can also accept the delegate method that returns the column settings object. This overload allows you to add a column with specific settings (see the "Contact Name" column in this demo).
Note that the partial View with the CardView extension does not need to be strongly-typed.
Local Copy of this Demo
To inspect the source code for this demo on your machine, you must first install our components via the DevExpress Component Installer.
You can open a local copy of this online demo directly from this webpage (if using v20.2.8, 21.1.4 or higher).
The source code files for this demo are installed (by default) in the following directory:
Open CS Solution
\Users\Public\Documents\DevExpress Demos XX.X\Components\ASP.NET\CS\MVCxCardViewDemos