Skip to main content

Server Mode: Binding to a Data Source Using XPO

  • 3 minutes to read

To enable a server mode (regular or Instant Feedback) you need to create an appropriate data source. You can use data sources provided by the eXpress Persistent Objects (XPO) library or use dedicated data sources tailored to work with ‘LINQ to SQL Classes’. This topic shows how to use data sources provided by the XPO library.

In this topic, the term grid control refers to a data-aware control that supports a server mode.

Server Mode: Binding to a Data Source Using eXpress Persistent Objects

To implement a server mode using data sources provided by the eXpress Persistent Objects (XPO) library, you should do the following.

Note

In a server mode, a target data table must contain a key field. If the table doesn’t contain a key field, it cannot be used as a data source in a server mode.

Providing Descriptive Information on the Target Data

When working with XPO, you need to provide descriptive information on the target data for a server mode data source you are using. To accomplish this, use the following approach.

In code, create a persistent class derived from the XPBaseObject or its descendant that will correspond to the target data table (data view) in the data store. Assign the class’ type to the XPServerCollectionSource.ObjectClassInfo or XPInstantFeedbackSource.ObjectType property. Building the project after creating the class allows you to initialize these properties at design time.

For information on creating persistent classes, please refer to the Basics of Creating Persistent Objects for Existing Data Tables topic.

Providing Connection Settings

You need to provide connection settings to enable XPO to connect to a required data store. There are multiple methods to provide connection settings:

The following code shows how to provide connection settings to the NorthWind database stored on the local MS SQLServer. The connection string is generated by the static MSSqlConnectionProvider.GetConnectionString method, which takes the names of the server and database, user name and password as parameters.

using DevExpress.Xpo;
using DevExpress.Xpo.DB;

XpoDefault.ConnectionString = MSSqlConnectionProvider.GetConnectionString(
  "(local)", "sa", "", "NorthWind");

See the Grid Server Mode and Grid Instant Feedback UI demos for complete examples of implementing server modes.

See Also