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)

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
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)

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

Left by KC at 10/26/2010 4:08 PM
Gravatar
thank you!!!!!!! this was exactly my problem and this is the only reference that I've found, has saved my sanity :)

Your comment:



(not displayed)


 
 
 
 
 

Live Comment Preview:

 
«February»
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910