Linq Data Source - adding a where clause
Posted on 2011-09-12
Newby question related to LINQ and LINQ DataSource.
I have a standard ASP web page with a gridview attached to a linq data source. A sort order is applied to the data so the most important data is generally at the top but sometimes I need to search (a very simple search)...
I have the code working by putting a hard coded string into .Where but I am confident that is NOT the best way to do this.
.Where = "First_Name.Contains(@SearchText) or Last_Name.Contains(@SearchText)"
The rest of the story... I have 2 distinct searches based on a combo-box. 'Name' is shown above and 'Address' is the other one.
How do I use linq to apply different where clauses?