Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Samuel Kim #1
Re: Sorting Datagrid With Hyphen / Dash
Due to their sequence in the ASCII set, - (hyphen) comes before the
numbers.
One way you can get around this behavior is to replace the hyphens with
underscore(_) character and do comparison.
If you change the hyphens to underscore, then you will need to revert
the changes once you are done - this you may not like so much.
To overcome this you can implement a class that implements the
IComparator interface and pass it along to the sort mechanism - the
IComparator instance can read the strings replace hyphen to underscore
and then compare. This will not require a change of your original data
and hence may be a cleaner solution - except for the fact that you need
to create another class.
Samuel Kim Guest
-
Datagrid sorting
I have read most messages in regard with this topic, and have tried every measure suggested. I'm still haveing problem to get it to work.... -
Sorting in the DataGrid
It's like this: a column in a DataGrid(u know, the component) receives several numbers from an XML,one for each cell, numbers from 0 to 11. Each nr... -
DataGrid Not Sorting
My web datagrid isn't sorting at all. I have it wired up to a handler, and I know the handler is working (being called), but no sorting. The page... -
sorting a datagrid
In asp.net I have created a datagrid which it data source is determined at runtime. How can add the auto sort functionality to this datagrid? In... -
Sorting in a DataGrid with no headings
I have got a scrollable datagrid within a Div tag and a fixed header created using an HTML table. I would like to be able to sort the datagrid by... -
Chris Mayers #2
Re: Sorting Datagrid With Hyphen / Dash
Thanks for your answer, I kind of understand what you are saying, but do you
have any code samples that would make it a little clearer?
However, this still does not really explain exactly what is going on with
the sorting at the moment.
ie
30-199
30-299
303-01
303-02
30-399
30-499
Regardless of the ASCII value of the hyphen, this sort order is WRONG, all
the '30-' codes should be together, and all the '303' codes should be
together. This sequence only makes sense if you ignore the hyphen completly,
ie:
30199
30299
30301
30302
30399
30499
Therefore, I draw the conclusion that tha DataGrid treats the hyphen as a
'special' character for the purposes of sorting. I guess this is because if
you were sorting proper words you would want (say) 'co-operative' to be
sorted next to 'cooperative'. But surely this behaviour should be
controllable...?? :-/
ALL I want is a way of getting the DataGrid (or DataView) to sort the data
with a proper ASCII sort, without any 'special casing' being applied to any
of the characters...
Anyone got any suggestions on that??
Cheers,
Chris.
"Samuel Kim" <look341@gmail.com> wrote in message
news:1110325517.500209.265740@o13g2000cwo.googlegr oups.com...> Due to their sequence in the ASCII set, - (hyphen) comes before the
> numbers.
> One way you can get around this behavior is to replace the hyphens with
> underscore(_) character and do comparison.
>
> If you change the hyphens to underscore, then you will need to revert
> the changes once you are done - this you may not like so much.
>
> To overcome this you can implement a class that implements the
> IComparator interface and pass it along to the sort mechanism - the
> IComparator instance can read the strings replace hyphen to underscore
> and then compare. This will not require a change of your original data
> and hence may be a cleaner solution - except for the fact that you need
> to create another class.
>
Chris Mayers Guest



Reply With Quote

