Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Expand]Controls and Libraries
 [Collapse]Common Features
  [Collapse]Data Binding Common Concepts
    How to: Bind GridControl to Database and Implement Master-Detail Mode at Design Time
    How to: Bind a Control to a Database at Runtime
    How to: Bind a Control to Data Created at Runtime
    How to: Bind a Control to Data in an XML File
    Traditional Data Binding Methods
    Data Source Configuration Wizard
    Data Binding Mechanism in ADO.NET
    Binding Controls to XML Data
    Binding Controls to Data Created at Runtime
    Add Unbound Data to a Data-Aware Control (XtraGrid, XtraPivotGrid)
    Binding to Excel Data Sources
    Binding to LINQ to SQL Classes
    Unbound Sources
    Binding to Entity Framework Core
    Binding to OData
    Binding to SQL Data
    Data Annotation Attributes
    How to: Add Virtual Rows Using the UnboundSource Component
    Obtaining Fields Available in Data Source
  [Expand]Data Source Wizard
  [Expand]Expressions
  [Expand]Behaviors
  [Expand]Application Appearance
  [Expand]Filtering UI Context
  [Expand]High DPI Support
  [Expand]Scaffolding Wizard
  [Expand]Formatting Values
   HTML Text Formatting
  [Expand]Menus
  [Expand]Tooltip Management
  [Expand]Saving and Restoring Layouts
   Clipboard - Copy and Paste Operations. Data Formatting
   Version Compatibility: Default Property Values
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Unbound Sources

The UnboundSource component is designed for unconventional binding scenarios when no strongly typed data set is available. The event-based nature of this component allows you to manually control what data is loaded into a data-aware control and how changes are saved.

Expanded Connect a Control to UnboundSource using the Data Source Configuration Wizard

The Data Source Configuration Wizard is the most handy way of binding DevExpress data-aware controls to any supported data source type. In this article, binding the Data Grid is taken as an example.

  1. Invoke the wizard by clicking the icon in the Data Grid control's bottom left corner.

  2. Select the "Unbound Data Source" option. The list on the wizard's right will display any existing unbound sources. You can select one of them or click the "New Data Source..." button, then click "Next" to proceed.

  3. If you have selected an existing UnboundSource, the wizard will ask you to set the row count for this source. This value sets the total number of records your data-aware component will receive.

    Otherwise, if you have created a new source, you will see a Collection Editor dialog instead. Utilize this dialog to create data fields for the UnboundSource component. For the sample data used in this example, you will need to create two data fields - "Int" and "String".

  4. Customize your data-aware control in accordance with the data fields added to the UnboundSource component. For the Data Grid control, you need to create a GridColumn for each data field. The most convenient way to do so is to invoke the Grid Designer, switch to its "Columns" tab and click the "Retrieve Fields" button.

  5. Handle the ValueNeeded/ValuePushed events to supply your grid with data and save modified data to storage.

Expanded Connect a Control to UnboundSource Manually

You can use the UnboundSource component directly to bind any third-party data-aware control that cannot be bound using the Data Source Configuration Wizard.

  1. Drop the UnboundSource component onto your form.
  2. Locate the Properties line in Visual Studio's Property Grid and click its ellipsis button. This will invoke the Collection Editor dialog. Using this dialog, create data fields that match your existing data source. For the sample data used in this example, you will need to create two data fields - "Int" and "String".

  3. Set your UnboundSource component as a data source for the required data-aware control.

  4. Customize the data-aware control according to data source fields. For Data Grid, you will need to create two GridColumn objects and specify their GridColumn.FieldName properties to match your data fields. The most convenient way to do so is to invoke the Grid Designer, switch to its "Columns" tab and click the "Retrieve Fields" button.

  5. Use the component's SetRowCount method to specify the initial amount of data source records.
  6. Handle the ValueNeeded/ValuePushed events to supply your grid with data and save modified data to storage.

Expanded Handle Data Requests and Updates

Show Me

The complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T474976.

After a control has been connected to UnboundSource, you need to transfer data to the control from the source. For this task UnboundSource raises the ValueNeeded event. This event will fire multiple times depending on the UnboundSource RowCount property value. The separate ValuePushed event allows you to save the modified control data back to storage.

The code below illustrates how to fetch data to the control from the "DefaultStringData" array and write modified data portions to the "Differences" dictionary.

To remove all data-aware control data, set the RowCount property to zero by calling the SetRowCount method.

Expanded See Also

How would you rate this topic?​​​​​​​