DataTable 排序

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 = "款 asc,項 asc,目 asc"; 
//过滤重复数据 
//DataTable dt = dv.ToTable(true, "款", "項", "目"); 
//不过滤重复数据 
DataTable dt = dv.Table.Copy();   


 

来源:http://www.cnblogs.com/fmxyw/archive/2008/10/08/1306554.html

你可能感兴趣的:(DataTable 排序)