0

hello guys

I have a data grid view with the following rows customerID, customerName, credit, debt. how do I implement filtering based on the customerID. I want to basically perform a search and display the results.

thanks.

4
Contributors
10
Replies
35
Views
2 Years
Discussion Span
Last Post by Emma Etigu
0

my records are in an access database. this is windows form. the data source of the data grid view is an access dataset

0

Ok so first question is how to users choose which id to search on - is that typed into a textbox maybe?

0

Sorry my previous post has a typo in which may make it unclear.

It should read

"Ok so first question is how do users choose which id to search on - is that typed into a textbox maybe?" - ie do instead of to

0

BindingSource is your friend:

private BindingSource _bs = new BindingSource();

...

// Initialize DGV
_bs.DataSource = ds.Tables("Customer");
dataGridViewCustomers.DataSource = _bs;

...

// Filter DGV
_bs.Filter = string.Format("customerID LIKE '%{0}%'", customerID);
0

thanks a lot for the idea. I used it and it worked though I incorporated it in the text change. but, I have another question. how do I refresh the data grid view after filtering? because with this technique, in case the data is not found the data grid view is empty but I want it to be refreshed so that a search can be performed again and if I select the filtered row I want the data grid view to also be refreshed.
thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.