How to update datagridView with results from search

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xinnie
    New Member
    • Jun 2010
    • 12

    How to update datagridView with results from search

    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.
  • sajjadlove
    New Member
    • Apr 2009
    • 19

    #2
    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:
    Code:
    select * from tb where tb.name like '%txtText%'
    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:
    Code:
    private void txtSearch_TextChanged(object sender, EventArgs e)
    {
      DataTable dtTemp = dt.Select("name like '%txtText%'");
      dbGrid.DataSource= dtTemp;
    }

    Comment

    • xinnie
      New Member
      • Jun 2010
      • 12

      #3
      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.

      Comment

      Working...