I have a web page with a GridView control populated from a database. I want to have a form that users can use to filter the results presented in the GridView. For example, it might have fields for last name, first name, department, wages, date of hire, etc. that the user can fill out to filter the results. Is there an elegant way of doing this? The only thing that comes to mind is to test the value of each field and then have a database query string for every outcome. For example, if the user only inputs a last name, the query might be SELECT * FROM EMPLOYEE ... WHERE LastName = @LastName. If they input both last name and department, the query would be SELECT * FROM EMPLOYEE ... WHERE LastName = @LastName AND Department = @Department. This seems like it would get unwieldy very quickly. Any suggestions on a better method?
View Complete Post