By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,709 Members | 2,211 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,709 IT Pros & Developers. It's quick & easy.

How to update datagridView with results from search

P: 12
Hi guys,

I have a form with datagridview, using access as my db. I have created a textbox with a search button, so what I want is; after entering the keyword for my search, i want my datagridview to be updated and give me the matching values.I'll be grateful for any help.
Jun 16 '10 #1
Share this Question
Share on Google+
2 Replies


P: 19
do you want to use from button for searching(push button)?
or when you enter a keyword in the TextBox(TextBox Text Changed)?

for using button:
not problem.you can write a query for searching.for example:
Expand|Select|Wrap|Line Numbers
  1. select * from tb where tb.name like '%txtText%'
  2.  
for entering keyword:
you can use from TextChanged event of the TextBox.and then use from Select method in the DataTable that you fill.for example:
Expand|Select|Wrap|Line Numbers
  1. private void txtSearch_TextChanged(object sender, EventArgs e)
  2. {
  3.   DataTable dtTemp = dt.Select("name like '%txtText%'");
  4.   dbGrid.DataSource= dtTemp;
  5. }
  6.  
Jun 16 '10 #2

P: 12
Sajjadlove,

What I want is when I choose a date OR enter a word in the textbox, I want my button to search it and bring the records.

I guess your codes help, I'll check now.
Thanks in advance.
Jun 16 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.