我需要在内存中根据来自GridView的列和方向使用DataTable。该功能需要如下所示:如何对给定列和方向的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;
}
损坏的链接排序中... 。 – Ash 2013-09-27 12:13:49
已更新的回答。谢谢。 – 2013-09-27 13:09:38