When using a SqlDataSource and stored procedure, I could do either a coalesce or write an if statement in the proc to return all if there is a certain parameter submitted.
- Thanks
LINQ Project General
The answer is pretty straight forward (thanks to Scott and his blog).
You can utilize the selecting event of the linqdatasource. Then search how you want using either a stored proc or linq language. Just rebind the grid when you want to use a search button.
You can also take advantage of the AutoGenerateWhereClause feature. When true, the Where clause will be automatically generated (using "==" and "AND") from all WhereParameters whose values are not null.
For instance, the following will use no Where clause (returning all rows) when the parameter value is null, and will use Where="CategoryID == @p1" when the parameter value is set:
<WhereParameters>
<asp:ControlParameter Name="CategoryID" ControlID="DropDownList1" Type="Int32" />
</WhereParameters>