Tuesday, February 1, 2011

SharePoint 2010 SPGridView Paging with ObjectDataSource

This is supposed to be simple: You setup an ObjectDataSource with paging, and you setup page size, pager mode, pager position, and pager visibility of the SPGridView. You would then expect that the SPGridView would show a pager when needed.
Well it is not that simple. The pager never shows up.
The solution turns out to be that you must set PagerTemplate of the SPGridView to null before data is bound to the SPGridView. A good place to do this is in the event handler of the "DataBinding" event of the SPGridView. Once it is set to null, the pager shows up and works perfectly.
I guess using pager template with ObjectDataSource is out of the question.

No comments:

Post a Comment