473,785 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Filtering Records in the datagridview

6 New Member
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 5644
BabliS1
6 New Member
@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,h ai

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 Recognized Expert Contributor
You can use datatable.Selec t 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
BabliS1
6 New Member
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 New Member
dataview.RowFil ter = "columnname like '%" & combobox1.Text & "'%"
Mar 24 '09 #5
BabliS1
6 New Member
@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(DG V) 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
11105
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 have a primary form named TestResults, which is connected to data in a table named TestResults. There are basically two other tables that are related to the TestResults table (and the primary form) named Names-Normalized and SiteAddresses. The...
0
1358
by: milk-jam | last post by:
How do i use the first raw of my datagridview for filtering the data in the datagridview ?
10
13358
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 that sort and one row for filtering and the lower one with no header for the data. Only it is very complicated to work this way cause for example when the user click on sort on the upper datagridview I need to sort the lower grid and so on when...
7
14820
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?
6
13550
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 that the user can type in any text and use that text as the filter. I would like to have this textbox row as the first row of the DataGridView just below the Header. I saw someone asking this question one year back but there was no solution...
7
16468
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 they can only input numerical values. Is there any way to do this? Currently my formatting works but if the user enters a value manually the formatting is not applied to the new value. Also I haven't found a way to allow only numerical input....
3
6633
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 implemented simultaneously for multiple columns - but the data need only be sorted by a single column at a time. Sorting should be both ascending and descending. I'm currently using a DataView but it's far too slow, because there are a large...
0
2004
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 from a file based on a search criterion. This basic functionality works just fine. I decided to allow the user to narrow down the output by providing some extra controls to allow the user to filter the recordset via the .Filter form property. ...
6
4157
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 have my first datagridview to have a multi-select (which i have currently), but what i want to happen when multiple rows are selected is different. I have a sub datagridview which is using a relationship in a dataset which allows the two...
0
9645
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
10325
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
10147
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
8972
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
5381
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
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
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
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.