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

Consult Primary Key in a DataGrid Textbox

tsanalista
P: 11
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?

Expand|Select|Wrap|Line Numbers
  1. //Code that lists all contacts in the Form
  2.   Public Sub AllContact(ByVal resul As Boolean)
  3.  
  4.         'Dim cliente As New Customers() 
  5.         Dim objContact As New DALContact()
  6.  
  7.         Try
  8.  
  9.             Dim ds As DataSet = objContact.AllContact() 
  10.  
  11.             Dim dt As DataTable = ds.Tables(0) 
  12.  
  13.             dv = dt.DefaultView
  14.  
  15.  
  16.             If ds.Tables(0).Rows.Count > 0 Then
  17.  
  18.                 With dv
  19.                     .AllowNew = False
  20.                     .AllowDelete = False
  21.                     .AllowEdit = False
  22.                     .Sort = " Pes_contact_Name ASC "
  23.  
  24.                 End With
  25.  
  26.  
  27.  
  28.                 gvContact.DataSource = dv
  29.                 bs.DataSource = ds
  30.  
  31.             End If
  32.  
  33.         Catch ex As Exception
  34.             MessageBox.Show(ex.Message)
  35.  
  36.                End Try
  37.  
  38.  
  39.     End Sub
  40.  
  41.  
  42.  
  43. //Code Textbox
  44. Private Sub txtSearchCustomers_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtBuscaClientes.TextChanged
  45.  
  46.         Try
  47.  
  48.             Dim txtstring As Integer= Me.txtSearchCustomers.Text
  49.  
  50.             If rdbIDCustomers.Checked = True Then
  51.  
  52.  
  53.                 Dim dv As DataView = Me.gvContact.DataSource
  54.                 dv.RowFilter = "Pes_contact_ID LIKE '" & txtstring & "%'"
  55.                 Me.gvContact.DataSource = dv
  56.  
  57.  
  58.             End If
  59.  
  60.  
  61.         Catch ex As Exception
  62.             Throw ex
  63.         End Try
  64.  
  65.  
  66.     End Sub
  67.  
Nov 20 '12 #1

✓ answered by tsanalista

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 + "%'"

Share this Question
Share on Google+
4 Replies


Rabbit
Expert Mod 10K+
P: 12,382
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.
Nov 20 '12 #2

tsanalista
P: 11
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 + "%'"
Nov 20 '12 #3

Rabbit
Expert Mod 10K+
P: 12,382
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?
Nov 20 '12 #4

tsanalista
P: 11
Yes, I found the problem .. thanks
Nov 21 '12 #5

Post your reply

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