cgipisani
asked on
Why does GridView paging not work when setting SqlDataSource SelectCommand attribute in code behind?
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.SelectComman d 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?
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.SelectComman
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I solved my problem by using a stored procedure instead of text command.