Question

I've implemented a custom sort for a aspxgridview, following the steps mentioned here: http://documentation.devexpress.com/#AspNet/CustomDocument3818

However, I've noticed that it only sorts the current active page, so whenever I go to another page I have to click again on the column to sort it.

Is this behavior correct, or am I missing something? How can I solve it?

PS: I thought about capturing the PageIndexChanged event and manually sort the active page, but that seems too hackish...

Was it helpful?

Solution

I have not checked your code, but it seems that your code does not work, because the date1.CompareTo method does not return -1, 0 or 1 values. It might return values less than zero, equal to it and more than zero.

Please check the e.Result property value, because it can accept only these three numbers.

By the way, I see that you have a date in literal format and are trying to convert string on the fly. I think that it might be easier for you to create an unbound column that should convert dates to the appropriate format, so that you will not be concerned about writing a custom sorting event handler.

Thanks,

Vest (DevExpress Support)

OTHER TIPS

What's wrong with the sorting? Are you expecting it to sort alphabetically?

That sample shows how to do custom sorting. So when you sort it, it uses the algorithm to check the length of the string and them sort by string length.

"This example shows how to implement custom sorting. The "Country" column displays text values. When sorting is applied to this column, the rows are compared by the length of the "Country" column values."

I've tested it and it seems to work correctly.

You may find this sample helpful too.

Hope that helps.

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