468,241 Members | 1,403 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,241 developers. It's quick & easy.

GridView - Changing FilterExpression of SQLDataSource and Paging

Environment: VS2005, ASP.Net 2.0, SQLServer 2000, VB.Net, IIS6

I use a GridView Control which is based on a SQLDataSource. The datasource
is based on a Select statement and is filtered by the FilterExpression. The
GridView also has a pager element (below, displaying first, previous, next,
last icons), paging is enabled, page contains 10 rows.

The user now skips some pages by clicking a view times on the next icon.
Now he changes the filter by entering a text in a text box.
This .Text property is thenafter used to set the
SQLDataSource.FilterExpression.

The displayed rows are correctly filtered and displayed, and paging works
fine. The only thing I don't understand is, why the pager doesn't reset to
page 1 if I change the FilterExpression. It just displays a page within the
resultset, not the first one. I even didn't find what page it displays, must
be an index or something it uses as it's not the same pagenumber as I had
before.
I also didn't find the method to request the first page after I've changed
the FilterExpression else I would use the textbox's TextChanged event to
reset the pager control to start at page 1.

Any idea how to do this? Or is it a bug? Do I have to do a workaround or
even stop using the FilterExpression and instead change the SQLCommand of
the SQLDataSource and manipulate the WHERE clause inside? I expect this
would result in disposing the cache and re-reading all records, what I don't
like for performance reasons.

Thanks for any hints on how to display the first page of a GridView control
programmatically after the FilterExpression of the SQLDataSource has
changed!

Greetings and TIA from Phuket, Thailand

Henry

Jan 20 '06 #1
1 6203
Got the answer:
<GridName>.PageIndex = 0
works fine. Must have been blind!

Henry

quoting Henry Habermacher [MVP Access]:
I also didn't find the method to request the first page after I've
changed the FilterExpression else I would use the textbox's
TextChanged event to reset the pager control to start at page 1.


Jan 23 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Bill Manring | last post: by
1 post views Thread by Andrew Nav | last post: by
4 posts views Thread by P. Yanzick | last post: by
4 posts views Thread by Bishop | last post: by
4 posts views Thread by David | last post: by
3 posts views Thread by Curt | last post: by
4 posts views Thread by Don Miller | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.