使用DataView
DataView dv = new DataView( dataTable );
dv.Sorting = "列名 排序方式"; //排序方式为ASC|DESC
------------------------------------------------------------
DataView dv = DataTable1.DefaultView;
dv.Sort = "id asc";
------------------------------------------------------------
//如果dataset已经取出来,那你的要求就不能一步实现了。
//1。使用DataTable的select这个方法,这个方法还可以用于过滤datarow
//2。再把排好序的datarow加入到datatable中
string strExpr = "";
string strSort = "column DESC";
DataRow[] dr = ds1.Tables[0].Select(strExpr,strSort);
ds1.Tables[0].Clear();
foreach(DataRow next in dr)
{
ds1.Tables[0].Rows.Add(next);
}
//大功告成!
9093




被折叠的 条评论
为什么被折叠?



