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

how to bind gridview to textbox to search

P: 9
hi, hope every one doing well

i want to link gridview to textbox that can use for search purpose ,if i double click in grid that can be shown in the category form
i attached some screen shoots for ref

thanks in advance

here is my catogery search code pls help me out

Expand|Select|Wrap|Line Numbers
  1. Imports System.Data.SqlClient
  2. Public Class catogorysearch
  3.     Dim con As New SqlConnection
  4.     Private Sub catogorysearch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  6.         con.ConnectionString = "Data Source=SHIVA\SQLEXPRESS2005;Initial Catalog=project_case;Persist Security Info=True;User ID=sa;password=pavanvsmginfo"
  7.         con.Open()
  8.         con.Close()
  9.         showitems()
  10.     End Sub
  11.     Private Sub showitems()
  12.         Dim dt As New DataTable
  13.         Dim ds As New DataSet
  14.         ds.Tables.Add(dt)
  15.         Dim da As New SqlDataAdapter
  16.         da = New SqlDataAdapter("SELECT * FROM category", con)
  17.         da.Fill(dt)
  18.         DataGridView1.DataSource = dt.DefaultView
  19.     End Sub
  21.     Private Sub BindingNavigator1_RefreshItems(ByVal sender As System.Object, ByVal e As System.EventArgs)
  23.     End Sub
  26.     Private Sub txtcat_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtcat.TextChanged
  28.     End Sub
  29.     Private Sub txtids_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtids.TextChanged
  31.     End Sub
  34. End Class

Attached Images
File Type: jpg pic1.jpg (146.3 KB, 715 views)
File Type: jpg pic2.jpg (132.0 KB, 757 views)
File Type: jpg Pic3.jpg (75.0 KB, 750 views)
Jun 28 '13 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,731
Well, it looks like you are handling the TextBoxes' TextChanged events but you aren't doing anything within the methods.

In those methods, you should either set DataGridView1.DataSource to a filtered version of the DataTable using the DataTable.Select method or you could re-query the the database using a where clause with the provided text (please use Parameterized Queries).

Jul 2 '13 #2

Post your reply

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