转自:http://www.cnblogs.com/ztf_yh/p/3765327.html 在此表示感谢! 一、重生法 dstaset.Tables.Add(dt) dataset.Tables(0).DefaultView.Sort = "id desc" -------------------------------------------------------------------------------- 二、直接法 dv = New DataView(dt) dv.Sort = "id desc" -------------------------------------------------------------------------------- 三、间接法 dv = New DataView(ds.Tables[0]) dv.Sort = "id desc" DataRow[] rows = dataTable1.Select("", "ord asc"); DataTable t = DataTable1.Clone(); t.Clear(); foreach (DataRow row in rows) t.ImportRow(row); DataTable1 = t; VS2005中这种方法最简单: DataView dv = dt.DefaultView; dv.Sort = "c1 Asc"; DataTable dt2 = dv.ToTable(); ---- //拿到数据源 DataView dv = this.dtDataSource.Copy().DefaultView; //排序 dv.Sort = "Columns1 asc,Columns2 asc,Columns3 asc"; //过滤重复数据 //DataTable dt = dv.ToTable(true, "Columns1", "Columns2", "Columns3"); //不过滤重复数据 DataTable dt = dv.Table.Copy();
来源:https://blog.csdn.net/guzicheng1990/article/details/99598873