Click here to Skip to main content
15,907,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I have a text box on a form and a database that stores first and last names, address, etc I wanna display on a repeater or datagrid all the details of the people who match any characters typed on the textbox whether its their stored email, Firstname lastname or telephone number...

Please I know it might be complex but any help will be really useful, just like how google searches
but i want it to search a single table.

Thank you in advance.
Posted
Comments
__TR__ 5-Sep-12 4:32am    
Look like you asked the same question twice. Please delete one of them.
mlingo209 5-Sep-12 4:43am    
Done! Thanks did not notice.

1 solution

It is actually not that difficult. What you are going to need to do is return all rows that CONTAIN the search string in any of the columns.

It is pretty simple to do with LINQ.

Unfortunately if you are writing the SQL statement yourself, it will be a pretty ugly mess of 'if firstname contains searchstring OR if lastname contains searchstring' ect.

Actually, the LINQ is pretty close to as ugly, but IMO is a bit easier to read.
 
Share this answer
 
v2
Comments
mlingo209 8-Sep-12 5:47am    
I did something worse I just retrieved all the rows and searched the list of objects in the BL class

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