Cgridview Does Not Paginate After Iterating Over Cdataprovider

I have a CSqlDataProvider object that I hand to a CGridView widget. Things work just fine, except before the CGridView is displayed to the user, I need to iterate over the dataprovider to do some data processing. I plugged the dataprovider into a CDataProviderIterator object, looped through the whole dataprovider and then called iterator->rewind(); Once I added the code to iterate over the object the CGridView stopped displaying correctly. The first page of the GridView is normal, but when the user clicks on the next button to view additional pages, nothing happens. Is this a problem with the iterator object or am I just doing something wrong?

Just to be sure, I commented out the code that iterates over the dataprovider and the gridview will display correctly and allow users to browse through all pages.

Has anyone run into this before?