|
-
Feb 17th, 2013, 02:00 PM
#1
Lively Member
Re: Search data from a Gridview or Dataset.
You could have another datatable and when the Search Text changes, copy the matching rows from the original to the shown datatable (or just unhook the DGV from the original dt and manually fill it each time.
Or set unmatched rows to visible=false in the DGV, if that's possible.
-
Feb 17th, 2013, 06:20 PM
#2
Re: Search data from a Gridview or Dataset.
 Originally Posted by geek648
You could have another datatable and when the Search Text changes, copy the matching rows from the original to the shown datatable (or just unhook the DGV from the original dt and manually fill it each time.
Or set unmatched rows to visible=false in the DGV, if that's possible.
Definitely don't do that.
The proper way to do this is via a BindingSource. Populate your DataTable, bind that to a BindingSource and then bind that to the DataGridView (NOT GridView, which is a different control altogether). To filter the data, simply set the Filter property of the BindingSource, e.g.
Code:
myBindingSource.Filter = String.Format("SomeColumn LIKE '{0}%'", myTextBox.Text)
-
Feb 17th, 2013, 09:55 PM
#3
Thread Starter
Lively Member
Re: Search data from a Gridview or Dataset.
Hello jmcilhinney,
You 're simply genius, that resolved and that too with the most effective solution.
Thanks a lot
-
Feb 18th, 2013, 02:52 AM
#4
Lively Member
Re: Search data from a Gridview or Dataset.
 Originally Posted by jmcilhinney
Definitely don't do that.
The proper way to do this is via a BindingSource.
Well at least I can serve as an example of how not to do it, LOL.
I'll get my coat.
Thanks for educating me
-
Feb 18th, 2013, 08:14 AM
#5
Re: Search data from a Gridview or Dataset.
 Originally Posted by geek648
Well at least I can serve as an example of how not to do it, LOL.
I'll get my coat.
Thanks for educating me 
Getting it wrong is usually the first step on the road to getting it right.
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
|