Sort DataTable

method one:

DataRow[] rows = dtStart.Select("", "Createdate asc");
DataTable dttwo = dtStart.Clone();
    dttwo.Rows.Add(row);
     dtStart= dttwo ;

Second way:

DataView dv = dt.DefaultView;
dv.Sort = "ID Asc";
dt = dv.ToTable();

The second is relatively simple, suitable for frequent use;

Reproduced in: https: //www.cnblogs.com/springyangwc/archive/2011/03/04/1971027.html

Guess you like

Origin blog.csdn.net/weixin_34061482/article/details/93340852