Question

By default, System.Web.UI.WebControls.DataGrid will sort String-based columns using a culture-sensitive sort. This can cause unexpected results when sorting product numbers that contain hyphens. For example, items will be sorted as 10-199, 103-10, 10-399 rather than 10-199, 10-399, 103-10.

Similar bug reports can be found at http://bytes.com/topic/net/answers/121496-sorting-datagrid-containing-dash-hyphen and http://connect.microsoft.com/VisualStudio/feedback/details/415793/dataview-sort-ignores-leading-dashes-hyphens-wrong-sort-order.

How can I have the DataGrid sort a column of Strings using a culture-insensitive sort?

Était-ce utile?

La solution

The only solution I have found is to create a new class inheriting from DataGrid and override the OnSortCommand method with your own custom sort.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top