By Greg McGuffey - 11/20/2006
I have a BO that is sorting on an int field (int in SQL Server). However the sorted results are as if the field was alpha-numeric. I.e. it sorts 1, 10, 11, 12, 2, ect. Am I missing a setting? The field is an Int32 in the BO.
|
By Trent L. Taylor - 11/20/2006
It should sort in integer order if the field created is in fact integer in the CurrentDataTable. All we do is set the sort in the DefaultView of the DataTable (CurrentView property of the BO). Open up the debugger, add the MyBO.CurrentDataTable to the watch window, and verify that the field is coming back as Int32.
|
By Greg McGuffey - 11/20/2006
Ah...I think the problem is that I'm using CopyData to fill a listbox and the listbox is sorting using alpha...the BO is sorting OK. I'll have to think of how to handle this.
|
By Greg McGuffey - 11/20/2006
The Sorted (of a listbox) property set to none...works great now...did I mention I was new to dotnet
|
By Trent L. Taylor - 11/20/2006
As I have mentioned before...I know that you won't have this problem again and I think that you said something about ... "Yeah, pain teaches"
|
By Trent L. Taylor - 11/20/2006
Just as a side note, you can get the behavior you want through a list...or any other type of object or collection for that matter. You can create a comparer object that compares two values any way that you like. In fact, the framework has a sorter for a ListView called the ListViewItemSorter. This can be used as a column sorter on a ListView.
|
By Greg McGuffey - 11/21/2006
I've read about the comparers. I'm sure I'll be using them at some point. And yeah, I won't soon forget this lesson...I've got the scares to remind me
|