日期:2014-05-19  浏览次数:20995 次

如何建表,排序
有一组数据,有n个ID值,ID为大小不定的整数,ID1=34,ID2=21...IDn=78。还有两列值,A1= "XX ",A2= "XX "..An= "xx ",B1= "XX ",   B2= "XX ",....,Bn= "yy ",ID和A,B是对应的,想建一个以ID,A,B为列,有n行的表,要求是能够排序,ID从小到大排列,(要求要先建表,再排序),请教如何建表,并用最简单的方法排序。

------解决方案--------------------
DataTable table = new DataTable();
DataColumn column = table.Columns.Add();
column.DataType = typeof(string);
column.ColumnName = "field1 ";
column = table.Columns.Add();
column.DataType = typeof(string);
column.ColumnName = "field2 ";

DataRow row = table.NewRow();
row[ "field1 "] = "21 ";
row[ "field2 "] = "22 ";
table.Rows.Add(row);

DataView view = table.DefaultView;
view.Sort = "field1 ";
------解决方案--------------------
也许wt_jn(含人)的办法简单一些
List <ReturnData> 是泛型