473,503 Members | 1,654 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid Filter

Hi all,
I have a DataTable and a DataGridView that is using it as a datasource.
I'm using the DataTable.Select method and I can find some rows. Is it now
possible, somehow to use the result of the Select method (a DataRow
collection) to make the DataGridView filtering only on those rows? I mean to
display only the found rows and after that to select all previous rows back
again? I want to use two buttons on my form "Apply Filter" and "Clear
Filter" to accomplish this.

Thanks for your time.
Paul

Sep 22 '07 #1
2 4604
This can much simpler ( if you program on framework 2 or higher )

Instead of using the select method on the datatable you would better create
a dataview object perform the filter on this object and bind this to the
datagridview
if you want to remove the filter well then you just rebind the original
datatable

HTH

Michel


"Paul" <pg*********@yahoo.grschreef in bericht
news:BE**********************************@microsof t.com...
Hi all,
I have a DataTable and a DataGridView that is using it as a datasource.
I'm using the DataTable.Select method and I can find some rows. Is it now
possible, somehow to use the result of the Select method (a DataRow
collection) to make the DataGridView filtering only on those rows? I mean
to
display only the found rows and after that to select all previous rows
back
again? I want to use two buttons on my form "Apply Filter" and "Clear
Filter" to accomplish this.

Thanks for your time.
Paul

Sep 22 '07 #2

Thank you very much Michel for your answer. I'm already using Framework 2.
Actually I found a different (and much flexible for my oppinion) approach
for this thing, using the BindingSource class as a datasource instead of the
datatable for my DataGridView object. Thus, all I have to do is to apply my
filter in BindingSource.Filter property and using the RemoveFilter method to
remove it.

Thanks again and have a nice day.

Paul

"Michel Posseth [MCP]" <MS**@posseth.comwrote in message
news:OB*************@TK2MSFTNGP06.phx.gbl...
This can much simpler ( if you program on framework 2 or higher )

Instead of using the select method on the datatable you would better
create a dataview object perform the filter on this object and bind this
to the datagridview
if you want to remove the filter well then you just rebind the original
datatable

HTH

Michel


"Paul" <pg*********@yahoo.grschreef in bericht
news:BE**********************************@microsof t.com...
>Hi all,
I have a DataTable and a DataGridView that is using it as a datasource.
I'm using the DataTable.Select method and I can find some rows. Is it now
possible, somehow to use the result of the Select method (a DataRow
collection) to make the DataGridView filtering only on those rows? I mean
to
display only the found rows and after that to select all previous rows
back
again? I want to use two buttons on my form "Apply Filter" and "Clear
Filter" to accomplish this.

Thanks for your time.
Paul

Sep 23 '07 #3

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

Similar topics

0
1011
by: amber | last post by:
Hello, I am having trouble with a datagrid. I received help online to create the datagrid the way I needed it, so I'm not entirely clear on how/why it works. I use the following code to...
1
1379
by: Guy Noir | last post by:
I am having trouble wrapping my head around a datagrid and datasource. I have it working, sort-of, but I'm having trouble refreshing my views. Here's what I have: A dataAdapter and dataSet...
2
3273
by: Alpha | last post by:
I have a window application. In one of the form, a datagrid has a dataview as its datasource. Initial filtering result would give the datavew 3 items. When I double click on the datagrid to edit...
3
1776
by: Pedor | last post by:
I want to display only data in the datagrid for specific records having a common or identical data in a column. How do you do this programmaticaly using combination of the datagrid object,...
2
2205
by: Mark Rae | last post by:
I've inherited an ASP.NET app and have been asked to fix the following problem with a page which is used to display and/or delete records from a database. When the page loads, it displays a list of...
9
3357
by: John Hernry | last post by:
I have been watching the dotnet newsgroups for a couple of weeks now and scouring the net looking for a solution to my datagrid find functionality. With no luck. I am hoping that you can help me....
3
2502
by: Datatable Dataset Datagrid help | last post by:
Hi I am somewhat confused, I am new at VB.net I use XML data, I have a datagrid, I created a datatable so that I can create a custom format like true is this graphic false is this graphic and...
17
2730
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
0
1447
by: Reena | last post by:
Hi, Working with ASP.NET 2.0 with Masterpages. Here is my datagrid... <asp:DataGrid ID="dgSelectedFields" runat="server" BorderStyle=None GridLines="None" CssClass="grdData"
0
2707
by: JamesOo | last post by:
I have the code below, but I need to make it searchable in query table, below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only,...
0
7072
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7271
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,...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5570
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,...
0
4666
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...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1498
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 ...
1
730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
373
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...

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.