|
-
Oct 30th, 2012, 01:36 AM
#2
Re: search filter for datagridview
This is actually very easy. You just query the database once. Get all the data into a DataTable, bind that to a BindingSource and bind that to your control(s). When you want to filter the data you simply set the Filter property of the BindingSource. The data in the DataTable is unaffected but the BindingSource only exposes rows that match the Filter, so that's all the user sees. Change the filter as much as you like and the view will refresh almost instantly as there is no database query.
The value you assign to the Filter property is basically a SQL WHERE clause, although only a subset of SQL syntax is supported. If you need help then the documentation for the DataColumn.Expression property explains all the supported syntax.
Also, if you want to access the data in code, you should do that via the BindingSource too.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|