how to bind gridview to textbox to search

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shivananda
    New Member
    • May 2013
    • 9

    how to bind gridview to textbox to search

    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

    Code:
    Imports System.Data.SqlClient
    Public Class catogorysearch
        Dim con As New SqlConnection
        Private Sub catogorysearch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
           
            con.ConnectionString = "Data Source=SHIVA\SQLEXPRESS2005;Initial Catalog=project_case;Persist Security Info=True;User ID=sa;password=pavanvsmginfo"
            con.Open()
            con.Close()
            showitems()
        End Sub
        Private Sub showitems()
            Dim dt As New DataTable
            Dim ds As New DataSet
            ds.Tables.Add(dt)
            Dim da As New SqlDataAdapter
            da = New SqlDataAdapter("SELECT * FROM category", con)
            da.Fill(dt)
            DataGridView1.DataSource = dt.DefaultView
        End Sub
    
        Private Sub BindingNavigator1_RefreshItems(ByVal sender As System.Object, ByVal e As System.EventArgs)
    
        End Sub
    
      
        Private Sub txtcat_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtcat.TextChanged
    
        End Sub
        Private Sub txtids_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtids.TextChanged
    
        End Sub
    
    
    End Class
    [imgnothumb]http://bytes.com/attachments/attachment/7062d1372414403/pic1.jpg[/imgnothumb]
    [imgnothumb]http://bytes.com/attachments/attachment/7063d1372414403/pic2.jpg[/imgnothumb]
    [imgnothumb]http://bytes.com/attachments/attachment/7064d1372414403/pic3.jpg[/imgnothumb]
    Attached Files
    Last edited by Frinavale; Jul 2 '13, 01:39 PM. Reason: Added images into body of thread
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    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.D ataSource to a filtered version of the DataTable using the DataTable.Selec t method or you could re-query the the database using a where clause with the provided text (please use Parameterized Queries).

    -Frinny

    Comment

    Working...