473,594 Members | 2,756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GridView - Changing FilterExpressio n 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 FilterExpressio n. 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.F ilterExpression .

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 FilterExpressio n. 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 FilterExpressio n 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 FilterExpressio n 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
programmaticall y after the FilterExpressio n of the SQLDataSource has
changed!

Greetings and TIA from Phuket, Thailand

Henry

Jan 20 '06 #1
1 6501
Got the answer:
<GridName>.Page Index = 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 FilterExpressio n else I would use the textbox's
TextChanged event to reset the pager control to start at page 1.


Jan 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
14793
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I want to look at that data and filter it based on what is in it. I know that this could have been done with data sets and data views in asp.net 1.1 but how is this done now in asp.net 2.0?
2
8097
by: Bill Manring | last post by:
I am writing a very simple web application using VS 2005 and a SQL Server Database. I am just starting to experiment wth .NET 2.0 and I am trying out the supposedly improved databinding. I dragged a table from a datasource on to my web form and the GridView cpntrol was created. I turned on paging, and Edit and Delete buttons. I ran the app and everything worked great - not a single line of code written yet. Then I wanted to add a...
1
1651
by: Andrew Nav | last post by:
I dragged a table from a datasource on to my web form and the GridView cpntrol was created. I turned on paging, and Edit and Delete buttons. I ran the app and everything worked great - not a single line of code written yet. Then I wanted to add a simple feature where the user could filter out data based on a value in a single column. I added a little code that set the FilterExpression property of the SqlDataSource, and that seemed...
4
4476
by: P. Yanzick | last post by:
Hello, I've been playing with master/detail views as well as editing in the gridview, and I ran across a strange problem that I am not exactly sure where to go to try to solve. I have 2 tables, a table of cars (pretty basic, an ID, a description, and a Color ID) and a table of colors (Color ID, and a color description). I've added a gridview and a detailsview as I'm playing with both and how to get editing features to work the way I...
4
7335
by: Bishop | last post by:
I have a number of simple select queries that a user needs to be able to execute and display the data on the screen in a gridview. My thought was that I could use a Gridview set to dymanically generate columns and bound to a SQLDataSource. Then the user can click buttons (or whatever) and it changes the SelectCommand property of the SQLDataSource and re-binds the GridView. That worked great until I enabled paging. When paging is...
4
11742
by: David | last post by:
I cannot get my aspx page (ASP.Net 2.0) to remove the FilterExpression on a SqlDataSource. Can someone tell me what I am doing wrong? Below is the SelectCommand: <asp:SqlDataSource ID="SqlClosedReason" runat="server" ConnectionString="<%$ ConnectionStrings:WcccuConnectionString %>" SelectCommand="SELECT NULL As seq_nbr, '-none-' As reason, 1 As active UNION SELECT , , FROM "
2
2215
by: kevinpond | last post by:
I have a Gridview displaying the results of a stored procedure. The stored procedure is constantly changing so the columns displayed in the data grid are constantly changing. I'd like to give users the ability to filter by the value of any column. This is easily done using the FilterExpression property of the DataSource. However, prior to creating the filter expression, I need to know if the column they wish to filter contains text or...
3
5158
by: Curt | last post by:
I have a gridview object with a sqldatasource as its sourceid. Everything was going so well until I came across this problem. My SELECTCOMMAND for my sqldatasource is: select alertid,subject,createdt,eventid,eventname, statuscd,trgid from vwAlerts order by createdt desc Now, based on a fiew input fields, I put together a WHERE clause for the filterexpression. For example, this filterexpression works great:
4
2716
by: Don Miller | last post by:
This is a repost of a reproducible problem/bug with GridView with dynamic SQL and binding. Is there a better ASP.NET newsgroup I should post to where MS techs or MVPs take an interest in such problems? Thanks. Here is an example of what I believe is a bug in ASP.NET 2.0 GridView paging without postbacks (or at least not documented how to fix it). Once the GridView is displayed, clicking on any of the paging tools causes the
0
7946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8251
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6654
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5408
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3897
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2385
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1478
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1210
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.