473,320 Members | 2,111 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,320 software developers and data experts.

Filtering Records in the datagridview

I am using Vb.net2005. I have a datagridview which displays some data. I want to filter the records based on some criteria given by the user at runtime. How can I do this. Please Help.

Thanks in Advance
Mar 24 '09 #1
5 5617
@BabliS1
I have a datagridview which displays some data. I want to filter the records based on some criteria given by the user at runtime.The form also contains a combobox.

The datagridview has a column which contains some string seperated by commas. Example:hello,hai

When the user selects an item from the combobox I want the datagridview to search the column data seperated by commas and display only those rows that includes the the specified string.
Currently I am using the Dataview to filter the records. But I dont understand how to search for a specified data within a string.

Could anyone please help me to filter the records in the dataview.

Thanks in Advance.
Mar 24 '09 #2
PRR
750 Expert 512MB
You can use datatable.Select method ....
Expand|Select|Wrap|Line Numbers
  1. string filterExp = "Status = 'Active'";
  2. string sortExp = "City";
  3. DataRow[] drarray;
  4. drarray = dataSet1.Customers.Select(filterExp, sortExp, DataViewRowState.CurrentRows);
  5. // clear your datatable
  6. for (int i=0; i < drarray.Length; i++)
  7. {
  8.    //add rows to datatable 
  9. }
  10. // bind here
  11.  
Mar 24 '09 #3
Thanks DeepBlue for your suggestion. But the problem is not solved.
Is it possible to use the split fuction with the RowFilter method.
If yes could you please tell me how.
Mar 24 '09 #4
aryanbs
42
dataview.RowFilter = "columnname like '%" & combobox1.Text & "'%"
Mar 24 '09 #5
@aryanbs
But the above line will check if the cell value starts with the specified text.I guess I was not clear in explaining my question.

My form contains a datagridview which is filled during the runtime based on some query. The form also contains a combobox whose items are some words.
The DataGridView(DGV) contains a column whose values are different words(only the ones contained in the datagridview) seperated by commas(Each row has different combination of words)
Now when the user selects a word from the combo I want the datagridview to display only those rows wherein the values for that cell contains the selected word.

Is it possible to split the contents of each cell with "," as the seperator and then compared each word with the selected word and display only that row that satisfies the condition and remove other rows.Currently I am using DataView to filter the records but I dont understand how to split the contents of the cell and compare it with the selected word.

Hope you understand what I meant
Please Help
Mar 24 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jason | last post by:
I am trying to filter records in a primary form based on records in related tables. The data in the related tables is being displayed in the primary form through subforms. To be more specific, I...
0
by: milk-jam | last post by:
How do i use the first raw of my datagridview for filtering the data in the datagridview ?
10
by: milk-jam | last post by:
I'm trying to set my datagridview so that the first row will be left blank and to use it as a filtering filed for the datagridview. Until now I was using 2 datagridview the upper one with a header...
7
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...
6
by: Satya | last post by:
Hi, I am using a DataGridView to display a large amount of data and so need to use filters for displaying certain data. For this I want to provide a textbox for each column of the DataGridView so...
7
by: Ryan | last post by:
I have a DataGridView which displays numeric (Int32) data from an underlying database. I want the numbers to be displayed in numeric format "#,###" (with commas). I want to also limit the user so...
3
by: Harry Haller | last post by:
Hello, I want to implement a generic list which will be used to display 7 columns in a GridView. One should be able to sort, filter and page each of the 7 columns. Ideally the filter should be...
0
by: Lyn | last post by:
I have a problem using the form .Filter and .FilterOn properties which causes Access to crash (as detailed in a separate post). The form operates in continuous mode, displaying matching records...
6
by: Gun Slinger | last post by:
Hi guys, I have a quick question which i have pondered for a little while. I'm not sure if its even a good idea (so maybe advice on whether or not to do it would be helpful as well). I want to...
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
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.