GridView - problem with paging

  • Thread starter Thread starter Iain
  • Start date Start date
I

Iain

All,

When changing the display of a GridView with :

SqlDataSource1.SelectCommand = "SELECT ....blah blah"
SqlDataSource1.DataBind();

After the result set changes within the Gridview the paging no longer
works, is there a way to re-page the control so it works correctly on
the newly displayed data.

Regards
Iain
 
All,

When changing the display of a GridView with :

           SqlDataSource1.SelectCommand = "SELECT ....blah blah"
           SqlDataSource1.DataBind();

After the result set changes within the Gridview the paging no longer
works, is there a way to re-page the control so it works correctly on
the newly displayed data.

Regards
Iain

What do you mean, why it no longer works? You probably need to set
PageIndex back to 0. Please look here for more examples:
http://msdn.microsoft.com/en-us/library/aa479347.aspx
 
Clicking on the pages seems to revert back to the previous result set.
I'll have a look at the suggested example!

Cheers Alexey.

It would be good to see your code. Maybe I can find the error there
 
Alexey said:
It would be good to see your code. Maybe I can find the error there

Code below, in a simplfied form :

I have a Button & a TextBox on a form and on the click of the button I
perform the following :

SqlDataSource1.SelectCommand = "SELECT id from mytable where name = '" +
TextBoxSearch.Text + "'";
SqlDataSource1.DataBind();

After applying the above the GridView refreshes as expected BUT clicking
on the page numbers within the GridView doesn't work as expected, it
displays records from the previous search.
 
Back
Top