How to sort a DataView in a case-insensitive manner?

那年仲夏 提交于 2019-11-30 09:34:03

问题


I have a DataTable. I'd like to sort its default view by a column name 'city'. I'd like the sort to be case-insensitive.

Here is the code I have:

DataTable dt = GetDataFromSource();
dt.DefaultView.Sort = "city asc";

MyReport.DataSource = dt.DefaultView;

Thanks.


回答1:


Never mind. It's in the documentation.

DataTable dt = GetDataFromSource();
dt.CaseSensitive = false;
dt.DefaultView.Sort = "city asc";


来源:https://stackoverflow.com/questions/521795/how-to-sort-a-dataview-in-a-case-insensitive-manner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!