DataControlField.SortExpression Property
.NET Framework (current version)
Gets or sets a sort expression that is used by a data source control to sort data.
Assembly: System.Web (in System.Web.dll)
[TypeConverterAttribute("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public virtual string SortExpression { get; set; }
Property Value
Type: System.StringA sort expression that is used by a data source control to sort data. The default value is an empty string ("").
The OnFieldChanged method is called to raise a state change event when the SortExpression property is set.
The value of the SortExpression property is stored in view state.
The following code example demonstrates how to use the SortExpression property to assign a sort expression to a data control field.
<%@ page language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>ASP.NET Example</title> </head> <body> <form id="form1" runat="server"> <asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="<%$ ConnectionStrings:MyNorthwind%>" selectcommand="Select * From Employees"> </asp:sqldatasource> <asp:detailsview id="DetailsView1" runat="server" allowpaging="True" datasourceid="SqlDataSource1" height="208px" width="264px" autogeneraterows="False"> <fields> <asp:boundfield sortexpression="LastName" datafield="LastName" headertext="LastName"> <itemstyle backcolor="Yellow"> </itemstyle> </asp:boundfield> <asp:boundfield sortexpression="FirstName" datafield="FirstName" headertext="FirstName"> <itemstyle forecolor="#C00000"> </itemstyle> </asp:boundfield> <asp:buttonfield text="TestButton" buttontype="Button"> </asp:buttonfield> </fields> </asp:detailsview> </form> </body> </html>
.NET Framework
Available since 2.0
Available since 2.0
Show: