Question

I'm having some trouble getting a GridView column of strings to sort properly.

The type of values in the column look like: $99,999, $200, /500, /50,000

Basically non-decimal currency values that may have a '/' instead of a '$'

Does anyone have a good approach to sorting these?

Was it helpful?

Solution

You could create a sort function that takes a set of strings, removes the first character, then sorts as normal. This would remove the $ or / issue.

To elaborate: create a new iComparer, and then have it return whether string1.SubString[1] > string2.SubString[1]. I'd write a bit of code, but I'm currently away from a computer with VS or Mono on it.

OTHER TIPS

Realized I can just set the sort expression of the BoundField to a different hidden column on the gridview (which contains the amount in a uniform itemCD string). Doh!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top