Using control SqlDataSource in .NET 2.0, how do I search for parameter when it is provided, and return all results when parameter is not provided.
For example:
On my page I have TextBoxSearch. If user type something in, and then click search button, I would like to perform something like: SELECT * FROM Customers WHERE LastName = @SearchParam in my datasource. If TextBoxSearch is empty I want all results from select statement returned: exp. SELECT * FROM Customers
How do I do this?
I've seen one example where ConvertEmptyStringToNull for parameter is used, then statement is constructed something like this: SELECT * FROM Customers WHERE LastName = IsNull(@SearchParam, LastName). Is this proper way?
For example:
On my page I have TextBoxSearch. If user type something in, and then click search button, I would like to perform something like: SELECT * FROM Customers WHERE LastName = @SearchParam in my datasource. If TextBoxSearch is empty I want all results from select statement returned: exp. SELECT * FROM Customers
How do I do this?
I've seen one example where ConvertEmptyStringToNull for parameter is used, then statement is constructed something like this: SELECT * FROM Customers WHERE LastName = IsNull(@SearchParam, LastName). Is this proper way?