asp.net.ph

DataControlField.SortExpression Property

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.

Syntax


Script DataControlField.SortExpression [ = strFieldName ]

Property Value


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.

Remarks

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.

Example

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;
}
  C# VB

 Show me 

See Also

DataControlField Members   Adding Sorting to a GridView Control Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph