.NET Framework Class Library DataView..::.Sort Property Gets or sets the sort column or columns, and sort order for the DataView.
Namespace:
System.Data
Assembly:
System.Data (in System.Data.dll)

Syntax
Public Property Sort As String
Get
Set
public string Sort { get; set; }
public:
property String^ Sort {
String^ get ();
void set (String^ value);
}
member Sort : string with get, set
Property ValueType: System..::.StringA string that contains the column name followed by "ASC" (ascending) or "DESC" (descending). Columns are sorted ascending by default. Multiple columns can be separated by commas.

Remarks
If you do not explicitly specify sort criteria for DataView, the DataRowView objects in DataView are sorted based on the index of its corresponding DataRow in the DataTable.Rows DataRowCollection. For more information, see DataViews (ADO.NET).

Examples
The following example instructs the DataView to sort the table by two columns.
Private Sub SortByTwoColumns()
' Get the DefaultViewManager of a DataTable.
Dim view As DataView = DataTable1.DefaultView
' By default, the first column sorted ascending.
view.Sort = "State, ZipCode DESC"
End Sub
private void SortByTwoColumns()
{
// Get the DefaultViewManager of a DataTable.
DataView view = DataTable1.DefaultView;
// By default, the first column sorted ascending.
view.Sort = "State, ZipCode DESC";
}

Version Information
.NET FrameworkSupported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0 .NET Framework Client ProfileSupported in: 4, 3.5 SP1

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

See Also
|
Biblioteca de clases de .NET Framework DataView..::.Sort (Propiedad) Obtiene o establece las columnas y el criterio de ordenación de DataView.
Espacio de nombres:
System.Data
Ensamblado:
System.Data (en System.Data.dll)

Sintaxis
Public Property Sort As String
Get
Set
public string Sort { get; set; }
public:
property String^ Sort {
String^ get ();
void set (String^ value);
}
member Sort : string with get, set
Valor de propiedadTipo: System..::.StringCadena que contiene el nombre de columna seguido de "ASC" (ascendente) o "DESC" (descendente). Las columnas se clasifican en orden ascendente de forma predeterminada. Varias columnas se pueden separar con comas.

Comentarios
Si no se especifican explícitamente los criterios de ordenación para DataView, los objetos DataRowView en DataView se ordenan de acuerdo con el índice del objeto DataRow correspondiente en DataTable.Rows DataRowCollection. Para obtener más información, vea DataViews (ADO.NET).

Ejemplos
En el ejemplo siguiente se indica al DataView que ordene la tabla mediante dos columnas.
Private Sub SortByTwoColumns()
' Get the DefaultViewManager of a DataTable.
Dim view As DataView = DataTable1.DefaultView
' By default, the first column sorted ascending.
view.Sort = "State, ZipCode DESC"
End Sub
private void SortByTwoColumns()
{
// Get the DefaultViewManager of a DataTable.
DataView view = DataTable1.DefaultView;
// By default, the first column sorted ascending.
view.Sort = "State, ZipCode DESC";
}

Información de versión
.NET FrameworkCompatible con: 4, 3.5, 3.0, 2.0, 1.1, 1.0 .NET Framework Client ProfileCompatible con: 4, 3.5 SP1

Plataformas
Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2
.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

Vea también
|