Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com
Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com

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 on Monday, October 22, 2007 8:06 PM ASP.NET , .Net Framework | Back to top


Comments on this post: DataView.Sort doesn't accept long name for direction

# re: DataView.Sort doesn't accept long name for direction
Requesting Gravatar...
I think the column name you have specified is not available in the DataTable in the DataView.

Please check it out!!!
Left by JG Vimalan on Jul 25, 2008 5:25 PM

# re: DataView.Sort doesn't accept long name for direction
Requesting Gravatar...
JG Vimalan,
I reviewed DataTable.ParseSortString in Reflector.
For .Net 2.0 it's definetely hardcoded to ASC and DESC(case insensitive)
Left by Michael Freidgeim on Jul 25, 2008 8:17 PM

# re: DataView.Sort doesn't accept long name for direction
Requesting Gravatar...
thank you!!!!!!! this was exactly my problem and this is the only reference that I've found, has saved my sanity :)
Left by KC on Oct 26, 2010 4:08 PM

Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net