System.Web.UI.WebControls Namespace DataControlField Class
.NET Framework version 2.0
Sets or retrieves the sort expression when a DataControlField is selected for sorting.
Script |
DataControlField.SortExpression [ = strFieldName ] |
strFieldName |
String representing the field name or expression to set the order of the data source bound to the parent control of a DataControlField |
The property is read/write with no default value.
Use the SortExpression property to specify or determine the field name or expression to set the order of the data source bound to the parent control of a DataControlField.
When AutoGenerateColumns for the parent control is true, the SortExpression property for each DataControlField is automatically set to the field name bound to the column. Otherwise ( when AutoGenerateColumns is false ), you need to manually set the SortExpression property for each column that you want to enable sorting for.
When a field is selected for sorting, the value of the SortExpression property for the selected field is passed to the event handler as part of the SortEventArgs of the parent control.
When multiple columns are sorted, this property contains a comma-separated list of the fields by which to sort.
The following example demonstrates how to access the SortExpression property contained in the GridViewSortEventArgs object, to determine which DataControlField was selected to set the sort order for a GridView control.
void getSortParams ( Object src, DataControlFieldSortEventArgs e ) {
msg.Text = "Current SortExpression: " + e.SortExpression;
msg.Text += ", SortDirection: " + e.SortDirection;
}
Sub getSortParams ( ByVal src as Object, ByVal e as DataControlFieldSortEventArgs ) {
msg.Text = "Current SortExpression: " & e.SortExpression
msg.Text += ", SortDirection: " & e.SortDirection;
End Sub
|
|
C# |
VB |
Show me
DataControlField Members Adding Sorting to a GridView Control