Export (0) Print
Expand All

DataGrid::AllowSorting Property

Gets or sets a value that indicates whether sorting is enabled.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public:
virtual property bool AllowSorting {
	bool get ();
	void set (bool value);
}

Property Value

Type: System::Boolean
true if sorting is enabled; otherwise, false. The default value is false.

When sorting is enabled, LinkButton controls are rendered in the heading section of each column where the SortExpression property is set. These LinkButton controls allow you to sort the DataGrid control by the selected column. The only exception is when you use a TemplateColumn column type with the HeaderTemplate property set. In this case, you must provide a Button control in the HeaderTemplate of the column.

The SortCommand event is raised when one of the LinkButton controls is clicked. It is up to you to provide code for the event handler. The typical logic for the handler is to sort the list, and then rebind the data to the DataGrid control.

The following code example demonstrates how to use the AllowSorting property to enable sorting.

No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1
Show:
© 2015 Microsoft