ASP.NET SqlDataSource, like on SelectCommand

EMTEC

New Member
I'm working on asp.net. I Have a \[code\]SqlDataSource\[/code\] with a query hardcoded on selectcommand:\[code\]<asp:SqlDataSource ID="DataSource1" runat="server" CancelSelectOnNullParameter="False" ConnectionString="<%$ ConnectionStrings:S.Properties.Settings.ConnectionString %>" SelectCommand="SELECT * FROM
WHERE ([col1] like Case @col1_param When null Then col1 Else @col1_param End) and ([col2] like Case @col2_param When null Then col2 Else @col2_param End)" SelectCommandType="Text"> <SelectParameters> <asp:ControlParameter ControlID="TextBox1" Name="col1_param" PropertyName="Text" Type="String" /> <asp:ControlParameter ControlID="TextBox2" Name="col2_param" PropertyName="Text" Type="String" /> </SelectParameters>\[/code\]What I want is that if you enter data on one textbox only, the data will display according with that textbox value only on the where clause. And if no values are placed for neither of the textboxes, the the query executes as if there is no where.Right now with this code,what happens is if you put on one textbox only no data is displayed. The same if all textboxes are empty.I don't want to use sql stored procedure. How can I solve this?Thanks...
 
Top