Data Access has been discontinued. Please refer to this page for more information.

Ordering Data

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

This topic demonstrates how to use the OpenAccessLinqDataSource control to order the retrieved records.

Ordering the Retrieved Records

The OrderBy tab on the second page of the wizard (the Configure Data Selection dialog) allows you to specify the columns you would like to order by.

Consider the snapshot above. The returned records will be ordered by the CategoryName column in Ascending order. Then, the records will be sorted by the CategoryID column in Descending order.

The following example shows the markup for part of an ASP.NET Web page that contains an OpenAccessLinqDataSource. The control is configured to enable the user to display all columns from a table named Categories. The returned records will be ordered by the CategoryName and CategoryID columns

<telerik:OpenAccessLinqDataSource
   ID="OpenAccessLinqDataSource"
   runat="server"
   ContextTypeName="OpenAccessLinqDataSourceDemo.EntitiesModel"
   ResourceSetName="Categories"
   EntityTypeName=""
   OrderBy="CategoryName, CategoryID desc">
</telerik:OpenAccessLinqDataSource>

How to: Enable/Disable Automatic Sorting in an OpenAccessLinqDataSourceControl

Some data-bound controls (e.g. RadGrid control) let users sort the data without requiring any code. The OpenAccessLinqDataSource control provides built-in support for sorting. The OpenAccessLinqDataSource control exposes the AutoSort property. The AutoSort property indicates whether the OpenAccessLinqDataSource control supports sorting the data at runtime. The default value for this property is True. If you want to disable the sorting functionality at runtime, you need to change the AutoSort property to False:

  1. Open your page in design mode and select the OpenAccessLinqDataSource control.
  2. Press F4 to open the Properties pane. Modify the AutoSort property. True to enable the sorting functionality; otherwise, False.
<telerik:OpenAccessLinqDataSource
   ID="OpenAccessLinqDataSource"
   runat="server"
   ContextTypeName="OpenAccessLinqDataSourceDemo.EntitiesModel"
   ResourceSetName="Categories"
   EntityTypeName=""
   AutoSort="False">
</telerik:OpenAccessLinqDataSource>

For a complete UI reference of the OrderBy tab page, check out the OrderBy Settings topic.