Back to Devexpress

XpoDataSource Class

xpo-devexpress-dot-xpo-68495522.md

latest3.9 KB
Original Source

XpoDataSource Class

A data source control that is a collection of persistent objects for ASP.NET controls.

Namespace : DevExpress.Xpo

Assembly : DevExpress.Xpo.v25.2.dll

NuGet Package : DevExpress.Xpo

Declaration

csharp
public class XpoDataSource :
    DataSourceControl,
    IXPClassInfoProvider,
    IXPDictionaryProvider
vb
Public Class XpoDataSource
    Inherits DataSourceControl
    Implements IXPClassInfoProvider,
               IXPDictionaryProvider

Remarks

The XpoDataSource component is an XPCollection counterpart for ASP.NET controls. In essence, the XpoDataSource component retrieves persistent objects from a data store and can be bound to a visual data-aware control (for example, ASPxGridView, ASPxNewsControl, ASPxCloudControl, etc.)

When creating an XpoDataSource , you should specify the type of objects to store. To do this, use the XpoDataSource.TypeName property.

aspx
<dxxpo:XpoDataSource ID="XpoDataSource1" 
                     runat="server" 
                     TypeName="Northwind.Order" 
                     Criteria="[ShippedDate] &gt;= ? And [ShippedDate] &lt; ?">
  <CriteriaParameters>
    <asp:ControlParameter ControlID="deStartDate" 
                          Name="@StartDate" 
                          PropertyName="Value" />
    <asp:ControlParameter ControlID="deEndDate" 
                          Name="@EndDate" 
                          PropertyName="Value" />
  </CriteriaParameters>
</dxxpo:XpoDataSource>

Link the XpoDataSource to a Session via the XpoDataSource.Session property, so that the data source can access the data store (database) to load and save persistent objects.

Use the XpoDataSource.Criteria property to specify how the collection is filtered during loading on the server side. The criteria expression should comply with Criteria Language Syntax.

csharp
using System;
using DevExpress.Xpo;
// ...
Session session1;
protected void Page_Init(object sender, EventArgs e) {
    session1 = new Session();
    XpoDataSource1.Session = session1;
    XpoDataSource1.Criteria = "[Age] > ?";
    XpoDataSource1.CriteriaParameters.Add("Age", TypeCode.Int32, "30");
}
vb
Imports System
Imports DevExpress.Xpo
' ...
Private session1 As Session
Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
    session1 = New Session()
    XpoDataSource1.Session = session1
    XpoDataSource1.Criteria = "[Age] > ?"
    XpoDataSource1.CriteriaParameters.Add("Age", TypeCode.Int32, "30")
End Sub

For more information on how to retrieve specific data, see How To: Connect XPO to a Database Server (ASP.NET WebForms).

Inheritance

Object Control DataSourceControl XpoDataSource

See Also

XpoDataSource Members

How To: Connect XPO to a Database Server (ASP.NET WebForms)

DevExpress.Xpo Namespace