If you are trying to find a row after a sort just by knowing its rownumber before the sort, then this will not work. Instead of just saving the rownumber, you need to save enough information to uniquely ID the row after the sort. One normal way of doing this is to use primary keys. This way, you can ID a row by checking its primary keys.
Below is a sample that allows you to click a button and set the backcolor of the current row using PrepareViewStyleInfo. It does this by saving the primary key of the colored row and looking for this key in PrepareViewStyleInfo to apply the color. To get the primary key of the current row, the button handler uses the code suggested above. This technique works even after the grid is sorted many times.
ColorRows.zip