DataView.Sort doesn't accept long name for direction

According to the documentation DataView.Sort  is a string that contains the column name followed by "ASC" (ascending) or "DESC" (descending). Columns are sorted ascending by default. Multiple columns can be separated by commas. 

If you pass long name: Descending or Ascending (from System.Web.UI.WebControls.SortDirection enum)

the error is reported:

System.IndexOutOfRangeException: Cannot find column LastName Descending. at System.Data.DataTable.ParseSortString(String sortString) at System.Data.DataView.UpdateIndex(Boolean force, Boolean fireEvent) at System.Data.DataView.UpdateIndex(Boolean force) at System.Data.DataView.SetIndex2(String newSort, DataViewRowState newRowStates, DataExpression newRowFilter, Boolean fireEvent) at System.Data.DataView.SetIndex(String newSort, DataViewRowState newRowStates, DataExpression newRowFilter) at System.Data.DataView..ctor(DataTable table, String RowFilter, String Sort, DataViewRowState RowState)

posted @ Monday, October 22, 2007 8:06 PM

Print

Comments on this entry:

# re: DataView.Sort doesn't accept long name for direction

Left by JG Vimalan at 7/25/2008 5:25 PM
Gravatar
I think the column name you have specified is not available in the DataTable in the DataView.

Please check it out!!!

# re: DataView.Sort doesn't accept long name for direction

Left by Michael Freidgeim at 7/25/2008 8:17 PM
Gravatar
JG Vimalan,
I reviewed DataTable.ParseSortString in Reflector.
For .Net 2.0 it's definetely hardcoded to ASC and DESC(case insensitive)

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345