如何排序给定列和方向的数据表?
我需要在内存中使用基于GridView的列和方向的DataTable。该函数需要如下所示: public static DataTable resort(DataTable dt, string colName, string direction) { DataTable dtOut = null; .... } 我需要填写此功能的帮助。我认为我可以使用Select语句,但不确定如何使用。由于使用此浏览器,我无法单击“注释”,但是您可以向我展示就地或新的DataTable解决方案,无论是哪种解决方案。对于那些向我展示指针的人,我需要一个类似于原型的编码函数。 怎么样: // ds.Tables[0].DefaultView.Sort="au_fname DESC"; public static void Resort(ref DataTable dt, string colName, string direction) { string sortExpression = string.Format("{0} {1}", colName, direction); dt.DefaultView.Sort = sortExpression; }