DataControlField.SortExpression Property
.NET Framework 3.0
Gets or sets a sort expression that is used by a data source control to sort data.
Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)
Assembly: System.Web (in system.web.dll)
[TypeConverterAttribute(L"System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public: virtual property String^ SortExpression { String^ get (); void set (String^ value); }
/** @property */ public String get_SortExpression () /** @property */ public void set_SortExpression (String value)
public function get SortExpression () : String public function set SortExpression (value : String)
Not applicable.
Property Value
A 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="VJ#" %>
<!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="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;"
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>
Community Additions
ADD
Show: