Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
 OrderGroupsBy Property
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
LinqDataSource..::.OrderGroupsBy Property

Gets or sets the fields that are used for ordering grouped data.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)
Visual Basic (Declaration)
Public Property OrderGroupsBy As String
Visual Basic (Usage)
Dim instance As LinqDataSource
Dim value As String

value = instance.OrderGroupsBy

instance.OrderGroupsBy = value
C#
public string OrderGroupsBy { get; set; }
Visual C++
public:
property String^ OrderGroupsBy {
    String^ get ();
    void set (String^ value);
}
JScript
public function get OrderGroupsBy () : String
public function set OrderGroupsBy (value : String)
ASP.NET
<asp:LinqDataSource OrderGroupsBy="String" />

Property Value

Type: System..::.String
A string that is used to create the Order Groups By clause.

You use the OrderGroupsBy property to specify how the groups of data are sorted. For example, you can group by the CategoryID property and then sort each category ID group by the average of the Price property.

You can set the OrderGroupsBy property only when you have grouped the data. If you set the OrderGroupsBy property without setting the GroupBy property, the LinqDataSource control throws an exception.

The property that is used to sort the data must be either a property that is used to group the data, or the result of an aggregation function on the grouped data. To specify how the data is sorted, you can add a space and the string "Ascending", "ASC", "Descending", or "DESC" to a property name in the OrderGroupsBy string.

You can specify more than one property in the OrderGroupsBy property. Separate each property by using a comma.

The following example shows how to group the data by using two properties, and how to sort the grouped data by using one of those properties. The data from a table named Products is grouped by using properties named CategoryID and Discontinued. The grouped data is sorted by the CategoryID property.

Visual Basic
<asp:LinqDataSource 
   ContextTypeName="DataClassesDataContext" 
   TableName="Products" 
   GroupBy="new (CategoryID, Discontinued)" 
   OrderGroupsBy="Key.CategoryID"
   Select="new(Key.CategoryID, Key.Discontinued, Average(UnitPrice) As AvePrice)" 
   ID="LinqDataSource1" 
   runat="server" >
</asp:LinqDataSource>
C#
<asp:LinqDataSource 
   ContextTypeName="DataClassesDataContext" 
   TableName="Products" 
   GroupBy="new (CategoryID, Discontinued)" 
   OrderGroupsBy="Key.CategoryID"
   Select="new(Key.CategoryID, Key.Discontinued, Average(UnitPrice) As AvePrice)" 
   ID="LinqDataSource1" 
   runat="server" >
</asp:LinqDataSource>

The following example shows how to group the data by using a property, and how to sort it based on the results of an aggregation function. The data from the Products table is grouped by using the CategoryID property. It is sorted based on the average of the UnitPrice property within each group.

Visual Basic
<asp:LinqDataSource 
   ContextTypeName="DataClassesDataContext" 
   TableName="Products" 
   GroupBy="CategoryID" 
   OrderGroupsBy="Average(UnitPrice)"
   Select="new(Key, Average(UnitPrice) As AvePrice)" 
   ID="LinqDataSource1" 
   runat="server" >
</asp:LinqDataSource>
C#
<asp:LinqDataSource 
   ContextTypeName="DataClassesDataContext" 
   TableName="Products" 
   GroupBy="CategoryID" 
   OrderGroupsBy="Average(UnitPrice)"
   Select="new(Key, Average(UnitPrice) As AvePrice)" 
   ID="LinqDataSource1" 
   runat="server" >
</asp:LinqDataSource>

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker