Consult Primary Key in a DataGrid Textbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tsanalista
    New Member
    • Nov 2012
    • 11

    Consult Primary Key in a DataGrid Textbox

    Hello everyone good morning?
    Would you like some help on how to make an appointment with a DataGrid textbox using the filter to type in the textbox.
    Use this form here tried but failed. Could someone pass me a solution?

    Code:
    //Code that lists all contacts in the Form
      Public Sub AllContact(ByVal resul As Boolean)
    
            'Dim cliente As New Customers() 
            Dim objContact As New DALContact()
    
            Try
    
                Dim ds As DataSet = objContact.AllContact() 
    
                Dim dt As DataTable = ds.Tables(0) 
            
                dv = dt.DefaultView
    
               
                If ds.Tables(0).Rows.Count > 0 Then
    
                    With dv
                        .AllowNew = False
                        .AllowDelete = False
                        .AllowEdit = False
                        .Sort = " Pes_contact_Name ASC "
    
                    End With
    
    
    
                    gvContact.DataSource = dv
                    bs.DataSource = ds
                    
                End If
    
            Catch ex As Exception
                MessageBox.Show(ex.Message)
    
                   End Try
    
    
        End Sub
    
    
    
    //Code Textbox
    Private Sub txtSearchCustomers_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtBuscaClientes.TextChanged
    
            Try
    
                Dim txtstring As Integer= Me.txtSearchCustomers.Text
    
                If rdbIDCustomers.Checked = True Then
    
    
                    Dim dv As DataView = Me.gvContact.DataSource
                    dv.RowFilter = "Pes_contact_ID LIKE '" & txtstring & "%'"
                    Me.gvContact.DataSource = dv
    
             
                End If
    
    
            Catch ex As Exception
                Throw ex
            End Try
    
    
        End Sub
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You haven't told us what the problem is. What's failed? You need to describe it so we know what needs to be fixed. If you're getting error messages, we need to know what those are and which lines the errors are on.

    Comment

    • tsanalista
      New Member
      • Nov 2012
      • 11

      #3
      Okay thanks, but just getting here ... now thanks .. was missing I do a conversion here on the field. Type this:
      dv.RowFilter = "Convert (Pes_contato_ID , 'System.String' ) LIKE '%" + txtString + "%'"

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        I don't understand what you just said. Are you saying that you've found the solution and no longer need an answer to your question?

        Comment

        • tsanalista
          New Member
          • Nov 2012
          • 11

          #5
          Yes, I found the problem .. thanks

          Comment

          Working...