|
-
Sep 3rd, 2014, 10:01 PM
#2
Re: Filtering DataGridView from textboxes
Firstly, don't keep creating a new DataView each time. A DataTable already has an associated DataView and, when you bind the DataTable, that's where the data comes from. What you should do is add a BindingSource to your form in the designer and then, when you populated the DataTable, bind it to the BindingSource and bind the BindingSource to the grid. Each time you want to change the filter, you simply set the Filter property of the BindingSource.
As for filtering by ID, it's pretty much the same as what you have now, i.e. you specify the column to filter by, the operator to compare with and the value to compare to. Obviously you can't use LIKE because that's just for text. You'll probably use = but any numerical comparison operator is valid. If you're not using LIKE then obviously wildcards aren't going to be used and also numerical values are not wrapped in single quotes the way text values are. Other than that, it's the same.
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
|