Click here to Skip to main content
15,889,200 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi guys,

I just found linq to entities. I decided to use it in my program.

I have a database with Sql server 2014. I imported my database with the help of "Ado.net entity data model".

Until then everything is fine, I created a context and I binded it on a bindingsource and the bindingsource is binded to my datagridview.

The problem is that when I come to filter my datagridview with the help of bindingsource.filter, nothing happens.

Did I make a mistake somewhere? Or is it the fact that it is a list that does not allow to filter?

Otherwise, would there be another way I could use with the help of entity framework to filter a datagridview?

ps: completeInventory is a stored procedure that select multiple field in multiple table.

What I have tried:

VB
  bindingsource.DataSource = entitiesCOOP.completeInventory.ToList()
dgv.DataSource = bindingsource

bindingsource.Filter = String.Format("description LIKE '" & txt_description.Text & "'")
 dgv.Refresh()
Posted
Updated 27-Nov-16 13:08pm
v2

1 solution

Your "filter" has nothing to do with Entity Framework. What you're using is normal everyday BindingSource Filtering.

Your filter doesn't work probably because you have no wildcards in the filter expression:
description LIKE '%something%'

will find any record with a description that contains 'something' anywhere in the description field.

Drop the beginning or trailing '%' sign and you can filter on descriptions beginning with or ending with the search word.
 
Share this answer
 
Comments
Member 12754823 27-Nov-16 21:00pm    
I already try it and it didn't work. I'm using a list(of t) and i did a couple of research about it and for some reasons, apparently the list(of t) is difficult to use with a filter. Is it a better way to filter a gridview?
Dave Kreskowiak 27-Nov-16 21:21pm    
Put the data in a DataTable instead of a List<t>.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900