I have a search page with multiple search criteria
etc
U
This is easy to do without any complex or expensive logic, in a single line...
Assuming that your three variables are @name, @surname, and @gender.
Also assuming that a zero-length string will be provided when a filter is not required.
Then, your Select statement is simply:
select * from table_name where (name = @name or @name = '') and (surname = @surname or @surname = '') and (gender = @gender or @gender = '')
That's all there is to it! No complex or expensive logic.