This documentation is archived and is not being maintained.

DataGrid.AllowSorting Property

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

[Visual Basic]
Public Overridable Property AllowSorting As Boolean
[C#]
public virtual bool AllowSorting {get; set;}
[C++]
public: __property virtual bool get_AllowSorting();
public: __property virtual void set_AllowSorting(bool);
[JScript]
public function get AllowSorting() : Boolean;
public function set AllowSorting(Boolean);

Property Value

true if sorting is enabled; otherwise, false. The default value is false.

Remarks

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.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

DataGrid Class | DataGrid Members | System.Web.UI.WebControls Namespace | SortCommand | LinkButton | Button | TemplateColumn | HeaderTemplate

Show: