asp.net.ph

DataGridColumn.SortExpression Property

System.Web.UI.WebControls Namespace   DataGridColumn Class


Sets or retrieves the field name or expression to pass to the DataGridSortCommandEventHandler when a column is selected for sorting.

Syntax


Script DataGridColumn.SortExpression [ = strFieldName ]

Property Value


strFieldName The field name or expression to sort the DataGridColumn by.

The property is read/write with no default value.

Remarks

Use the SortExpression property to specify or determine the name of the field to pass to the SortCommand event handler when a column is selected for sorting.

When AutoGenerateColumns is true, the SortExpression property for each column in the DataGrid is automatically set with 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.

The value of the SortExpression property for the selected column is passed to the SortCommand event handler as part of the DataGridSortCommandEventArgs object.

Example

The following example demonstrates how to access the SortExpression property of a DataGridSortCommandEventArgs object, to determine which column the user selected to sort the DataGrid control by.

void sortGrid ( Object src, DataGridSortCommandEventArgs e ) {
   DataView myView = fetchData ( query, "northwind" ).Tables [ 0 ].DefaultView;
   myView.Sort = e.SortExpression;
   myGrid.DataSource = myView;
   myGrid.DataBind ( );
}
  C# VB

 Show me 

See Also

DataGridColumn Members   DataGridSortCommandEventArgs   DataGridSortCommandEventHandler 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