Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

EntityDataSource.AutoGenerateOrderByClause Property

Gets or sets a value that indicates whether the EntityDataSource control dynamically creates an ORDER BY clause based on values in the OrderByParameters collection.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web.Entity (in System.Web.Entity.dll)

public bool AutoGenerateOrderByClause { get; set; }
<asp:EntityDataSource AutoGenerateOrderByClause="True|False" />

Property Value

Type: System.Boolean
true if the EntityDataSource control creates the ORDER BY clause; otherwise false. The default value is false.

ExceptionCondition
InvalidOperationException

When the AutoGenerateOrderByClause property is set to true and the OrderBy property is not null.

When the AutoGenerateOrderByClause property of the EntityDataSource control is set to true, the control automatically generates an ORDER BY clause from the parameter in the ParameterCollection assigned to the OrderByParameters property. This eliminates the need to explicitly assign an ORDER BY clause to the OrderBy property. The construction of the ORDER BY clause from the OrderByParameters property requires that the Name property of the parameter in the collection identifies a single property of the item returned from the query.

The default value for the AutoGenerateWhereClause property is false.

Null values are allowed for the values of the parameters supplied to the WhereParameters property when the AutoGenerateWhereClause property is set to true; when this occurs, the WHERE clause is omitted from the query.

The following example automatically generates the ORDER BY clause and uses the value of the orderByDropDownList to set the value of the parameter.

<asp:EntityDataSource ID="SalesOrderHeader" runat="server" 
    ConnectionString="name=AdventureWorksEntities"
    DefaultContainerName="AdventureWorksEntities" EnableDelete="True" 
    EnableInsert="True" EnableUpdate="True" EntitySetName="SalesOrderHeader" 
    Where="it.OnlineOrderFlag = true" AutoGenerateOrderByClause="True">
    <OrderByParameters>
        <asp:ControlParameter Name="OrderByParameter" 
            ControlID="orderByDropDownList" Type="String" />
    </OrderByParameters>
</asp:EntityDataSource>

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 SP1

Community Additions

ADD
Show:
© 2015 Microsoft