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 */
public boolean get_AllowSorting ()

/** @property */
public void set_AllowSorting (boolean value)

public function get AllowSorting () : boolean

public function set AllowSorting (value : boolean)

Property Value

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.

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show: