Why does GridView paging not work when setting SqlDataSource SelectCommand attribute in code behind?
Posted on 2006-10-26
I have a GridView tied to a SqlDataSource. TheSqlDataSource has SelectCommandType="Text".
The query string I'm looking to use will be dynamic. For testing though, I'm trying "Select * from myTable".
I'm seeing two different behaviors for paging in the GridView depending on where I set the SelectCommand attribute of the SqlDataSource.
1) When I try to set SqlDataSource.SelectCommand in my code behind, the first page of data works, but any subsequent pages have no data.
2) When I explicity put the SelectCommand in the GridView attributes, paging works fine. This method doesn't work for me as I must be able to dynamically change the SelectCommand for the SqlDataSource.
Where am I failing with my code behind?