关于对已经绑定的DataSet的排序的问题:

DataSet ds=new DataSet();
DataView dv=new DataView();
dv.Table=ds.Tables[0];
dv.Sort="CreateTime desc";
GridView.DataSource=dv;
就可以实现对dataset的排序了。

 

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();

============================

【追加】排序的好方法

            dt.DefaultView.Sort = "ID ,Name ASC";
            dt
=dt.DefaultView.ToTable();

相关文章:

  • 2022-03-01
  • 2021-12-09
  • 2022-02-20
  • 2022-01-16
猜你喜欢
  • 2021-07-29
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案