日期:2014-05-17  浏览次数:20987 次

DataTable如何实现排序

代码如下,我把dt加了一行之后再进行排序,加的那一行始终在最后要怎么处理才行?
C# code


            cbxItem.DataSource = null;
            DataRow dr = dt.NewRow();
            dr[0] = "!!! ";
            dt.Rows.Add(dr);
            dt.AsDataView().Sort = "item ASC";
            dt.AcceptChanges();
            
            cbxItem.DataSource = dt;
            cbxItem.ValueMember = "item";
            cbxItem.DisplayMember = "item";



------解决方案--------------------
DataView dView = dt.DefaultView;
dView.Sort = "item ASC";
dt = dView.ToTable();