Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
How to: Bind Objects to ASP.NET Controls
Programmer's Guide > OpenAccess ORM Classic (Old API) > OpenAccess Tasks > Bind Data to Controls > How to: Bind Objects to ASP.NET Controls

Glossary Item Box

This documentation article is a legacy resource describing the functionality of the deprecated OpenAccess Classic only. The contemporary documentation of Telerik OpenAccess ORM is available here.

Bind Object to ASP.NET Controls Using the OpenAccessDataSource

You can use the OpenAccessDataSource control to bind objects to ASP.NET controls. This technique will reduce the code behind dramatically. For more information regarding how to bind controls using the data source you can refer to this topic - OpenAccessDataSource QuickStart Example.

Bind Objects to ASP.NET Controls Using the Code Behind

Telerik OpenAccess ORM enables you to bind object using the code behind method as well. You can easily do this by retrieving all the objects that you wish to bind and taking advantage of the .DataSource property of the control to which you wish to bind the result set. The following examples shows how to retrieve a single column from a data table and bind it to RadComboBox:

C# Copy Code
var result = from c in scope.Extent<OpenAccessData.Order>()
            orderby c.OrderID
            select c.OrderID;
RadComboBox1.DataSource = result;
RadComboBox1.DataBind();
VB .NET Copy Code
Dim result = From c In scope.Extent(Of OpenAccessData.Order)() _
             Order By c.OrderID _
             Select c.OrderID
RadComboBox1.DataSource = result
RadComboBox1.DataBind()

This example shows how to bind a whole collection of fields which order ID matches some variable to a RadGrid.

C# Copy Code
var result = from c in scope.Extent<OpenAccessData.OrderDetail>() where c.OrderID == myValue select c;
           RadGrid1.DataSource = result;
           RadGrid1.DataBind();
VB.NET Copy Code
Dim result = From c In scope.Extent(Of OpenAccessData.OrderDetail)() _
             Where c.OrderID = myValue _
             Select c
   RadGrid1.DataSource = result
   RadGrid1.DataBind()