以下示例指示 DataView 按照两列对表进行排序。[Visual Basic] Private Sub SortByTwoColumns() ' Get the DefaultViewManager of a DataTable. Dim myDataView As DataView myDataView = DataTable1.DefaultView ' By default, the first column sorted ascending. myDataView.Sort = "State, ZipCode DESC" End Sub[C#] private void SortByTwoColumns() { // Get the DefaultViewManager of a DataTable. DataView myDataView = DataTable1.DefaultView; // By default, the first column sorted ascending. myDataView.Sort = "State, ZipCode DESC"; }
{
DataTable dttmp = table.Copy();
DataRow[] drs = dttmp.Select("1=1", "field1");// 按field1字段排序. table.Rows.Clear();
foreach(DataRow dr in drs)
{
table.Rows.Add(dr.ItemArray);
}
table.AcceptChanges();
}
Private Sub SortByTwoColumns()
' Get the DefaultViewManager of a DataTable.
Dim myDataView As DataView
myDataView = DataTable1.DefaultView
' By default, the first column sorted ascending.
myDataView.Sort = "State, ZipCode DESC"
End Sub[C#]
private void SortByTwoColumns()
{
// Get the DefaultViewManager of a DataTable.
DataView myDataView = DataTable1.DefaultView;
// By default, the first column sorted ascending.
myDataView.Sort = "State, ZipCode DESC";
}