开发者

Sorted dataview to datatable

开发者 https://www.devze.com 2023-01-20 14:19 出处:网络
I have the following method: 开发者_C百科private DataTable getsortedtable(DataTable dt) { dt.DefaultView.Sort = \"Name desc\";

I have the following method:

开发者_C百科private DataTable getsortedtable(DataTable dt)
{
    dt.DefaultView.Sort = "Name desc";
    //I would need to return the datatable sorted.
}

My issue is that I cannot change the return type of this method and I have to return a DataTable but i would like return it sorted.

Are there any magic hidden property of dt.DefaultView to return the dt sorted?


 private DataTable getSortedTable(DataTable dt)
 {
    dt.DefaultView.Sort = "columnName DESC";
    return dt.DefaultView.ToTable();
  }


do this

private DataTable getsortedtable(DataTable dt)
{
    //do the operation for sort   
    return dataView.ToTable();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号