Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am new to ado.net. I have a dataset that I am using to populate a datagridview. Under the grid I have a text box and I want the user to be able to filter the datagrid based on what they type in the box. As an example, if the user types an "A" then all people listed in the grid with the last name of "A" will show up. If they type "AB", only people starting with "AB" will show up. I use the WHERE LIKE '" & textbox1.text & "%' as my query. I don't want to have to requery the db each time. I understand that this can be done with the dataset but I don't know how. Any help would be greatly appreciated.

 

Shannan

Posted

The DataGridView has a Filter parameter that you can use many SQL filtering statements. like "Name = 'a'"

 

or as you would do it using VB.net (C# uses a plus sign instead of amperstand):

 

dgv.filter = "Name '" & textbox.text & "'"

dgv.refresh

 

or something very similar to that.

 

Lookup the Filter method in MSDN and they have an example of how it works.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...