Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Why does GridView paging not work when setting SqlDataSource SelectCommand attribute in code behind?

Posted on 2006-10-26
2
Medium Priority
?
2,649 Views
Last Modified: 2011-08-18
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?
0
Comment
Question by:cgipisani
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
Niraj_Singh earned 500 total points
ID: 17818470

 could you tell me what code did you write for the PageIndexChanged event of the datagrid. it would be easier for me to help you then.

private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
      ur code here....      
}
0
 

Author Comment

by:cgipisani
ID: 17821599
I didn't have anything for that function.

I solved my problem by using a stored procedure instead of text command.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question