I have a list of class
How can I filter on some condition..I am applying following it is working when value gets exact match
Dim result = obj.OfType(Of clsEmrItmMstr)().Where(Function(s) s.GenName Like txtserach.Text)
grddetails.DataSource = result
grddetails.DataBind()
where "clsEmrItmMstr" is my class name and "GenName" is field in class
Instead of the Like operator you could simply use String.Contains:
Dim result = obj.OfType(Of clsEmrItmMstr)().
Where(Function(s) s.GenName.Contains(txtserach.Text))
With Like you need * as wildcard, so this should work:
Dim result = obj.OfType(Of clsEmrItmMstr)().
Where(Function(s) s.GenName Like String.Format("*{0}*", txtserach.Text))
(assuming that you want to find all objects where the GenName contains the text entered in the TextBox)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With