GridView - problem with paging

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
 
G

Guest

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
 
G

Guest

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
 
I

Iain

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top