473,324 Members | 2,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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 4598
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
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
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
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
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
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
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
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
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
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
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.