datatable.sort倒序
时间: 2023-11-11 09:14:52 浏览: 91
要对DataTable进行倒序排序,可以使用DefaultView来实现。首先,将DataTable的DefaultView.Sort属性设置为需要的排序条件,其中排序条件是以列名 + "desc"的形式表示的,表示按照该列的降序排序。例如,如果要按照"price"列进行倒序排序,可以设置DefaultView.Sort = "price desc"。然后,将排序后的DefaultView赋值给DataGridView的DataSource属性,这样就可以显示倒序排序后的DataTable数据了。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [C# DataTable用法示例详解|DataTable Select,sort排序,Linq过滤操作](https://blog.csdn.net/weixin_33711795/article/details/114514799)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [DataTable某个字段倒序显示](https://blog.csdn.net/QingHeShiJiYuan/article/details/50409965)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文